PagerDuty
PagerDuty is an incident management platform that helps teams detect and respond to issues in real-time. rindexer can trigger PagerDuty incidents when on-chain events occur.
Setup a PagerDuty integration
- Log into your PagerDuty account and navigate to Services > Service Directory.
- Select an existing service or create a new one.
- Go to the Integrations tab and click Add an integration.
- Select Events API v2 and click Add.
- Copy the Integration Key (also called Routing Key). This is what you will use to send events.
Configure rindexer
pagerduty property accepts an array allowing you to split up the alerts any way you wish.
Example
name: RocketPoolETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
- name: ethereum
chain_id: 1
rpc: https://mainnet.gateway.tenderly.co
contracts:
- name: RocketPoolETH
details:
- network: ethereum
address: "0xae78736cd615f374d3085123a210448e74fc6393"
start_block: "18600000"
end_block: "18600181"
abi: "./abis/RocketTokenRETH.abi.json"
include_events:
- Transfer
chat:
pagerduty:
- routing_key: ${PAGERDUTY_ROUTING_KEY}
severity: critical
networks:
- ethereum
messages:
- event_name: Transfer
# filter_expression is optional
filter_expression: "from = '0x0338ce5020c447f7e668dc2ef778025ce3982662' || from = '0x0338ce5020c447f7e668dc2ef778025ce398266u' && value >= 10 && value <= 2000000000000000000"
template_inline: "New RETH Transfer Event
from: {{from}}
to: {{to}}
amount: {{format_value(value, 18)}}
RETH contract: {{transaction_information.address}}
etherscan: https://etherscan.io/tx/{{transaction_information.transaction_hash}}
"routing_key
This is your PagerDuty Events API v2 integration key (also called routing key). You can find it in your service's Integrations tab.
...
contracts:
- name: RocketPoolETH
details:
- network: ethereum
address: "0xae78736cd615f374d3085123a210448e74fc6393"
start_block: "18600000"
end_block: "18600181"
abi: "./abis/RocketTokenRETH.abi.json"
include_events:
- Transfer
chat:
pagerduty:
- routing_key: ${PAGERDUTY_ROUTING_KEY}severity
The severity level for the PagerDuty event. Must be one of: info, warning, error, critical. Defaults to critical.
...
contracts:
- name: RocketPoolETH
details:
- network: ethereum
address: "0xae78736cd615f374d3085123a210448e74fc6393"
start_block: "18600000"
end_block: "18600181"
abi: "./abis/RocketTokenRETH.abi.json"
include_events:
- Transfer
chat:
pagerduty:
- routing_key: ${PAGERDUTY_ROUTING_KEY}
severity: criticalnetworks
This is an array of networks you want to trigger PagerDuty events for.
...
contracts:
- name: RocketPoolETH
details:
- network: ethereum
address: "0xae78736cd615f374d3085123a210448e74fc6393"
start_block: "18600000"
end_block: "18600181"
abi: "./abis/RocketTokenRETH.abi.json"
include_events:
- Transfer
chat:
pagerduty:
- routing_key: ${PAGERDUTY_ROUTING_KEY}
severity: critical
networks:
- ethereummessages
This is an array of messages you want to trigger as PagerDuty events. It is an array as you can define many different messages with different conditions.
event_name
This is the name of the event you want to send a message for, must match the ABI event name.
...
contracts:
- name: RocketPoolETH
details:
- network: ethereum
address: "0xae78736cd615f374d3085123a210448e74fc6393"
start_block: "18600000"
end_block: "18600181"
abi: "./abis/RocketTokenRETH.abi.json"
include_events:
- Transfer
chat:
pagerduty:
- routing_key: ${PAGERDUTY_ROUTING_KEY}
severity: critical
networks:
- ethereum
messages:
- event_name: Transferfilter_expression
This accepts a filter expression to filter the events before triggering a PagerDuty event.
Filter expressions allow for condition checking of the event data and support logical operators to combine multiple conditions.
conditions
This accepts an array of conditions you want to apply to the event data before triggering a PagerDuty event.
template_inline
You can then write your own template inline, this is the template used as the PagerDuty event summary.
You have to use the ABI input names in object notation for example if i wanted to put value in the template
i just have to write {{value}} in the template and it will be replaced with the value of the event itself.
transaction_information
You also can use the transaction_information object to get common information about the transaction, this is the
transaction information for the event.
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct TxInformation {
pub network: String,
pub address: Address,
pub block_hash: BlockHash,
pub block_number: U64,
pub transaction_hash: TxHash,
pub log_index: U256,
pub transaction_index: U64,
}format_value
You can use the format_value function to format the value of the event to a decimal value with the specified decimals.
Lets put it all together:
...
contracts:
- name: RocketPoolETH
details:
- network: ethereum
address: "0xae78736cd615f374d3085123a210448e74fc6393"
start_block: "18600000"
end_block: "18600181"
abi: "./abis/RocketTokenRETH.abi.json"
include_events:
- Transfer
chat:
pagerduty:
- routing_key: ${PAGERDUTY_ROUTING_KEY}
severity: critical
networks:
- ethereum
messages:
- event_name: Transfer
template_inline: "New RETH Transfer Event
from: {{from}}
to: {{to}}
amount: {{format_value(value, 18)}}
RETH contract: {{transaction_information.address}}
etherscan: https://etherscan.io/tx/{{transaction_information.transaction_hash}}
"