OpsGenie
OpsGenie is an alert and incident management platform by Atlassian. rindexer can create OpsGenie alerts when on-chain events occur.
Setup an OpsGenie integration
- Log into your OpsGenie account at opsgenie.com.
- Navigate to Settings > Integration list.
- Search for API and click Add.
- Copy the API Key from the integration settings. This is what you will use to create alerts.
- Make sure the integration is enabled and saved.
Configure rindexer
opsgenie 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:
opsgenie:
- api_key: ${OPSGENIE_API_KEY}
priority: P1
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}}
"api_key
This is your OpsGenie API integration key. You can find it in your integration settings.
...
contracts:
- name: RocketPoolETH
details:
- network: ethereum
address: "0xae78736cd615f374d3085123a210448e74fc6393"
start_block: "18600000"
end_block: "18600181"
abi: "./abis/RocketTokenRETH.abi.json"
include_events:
- Transfer
chat:
opsgenie:
- api_key: ${OPSGENIE_API_KEY}priority
The priority level for the OpsGenie alert. Must be one of: P1, P2, P3, P4, P5. Defaults to P1.
P1- CriticalP2- HighP3- ModerateP4- LowP5- Informational
...
contracts:
- name: RocketPoolETH
details:
- network: ethereum
address: "0xae78736cd615f374d3085123a210448e74fc6393"
start_block: "18600000"
end_block: "18600181"
abi: "./abis/RocketTokenRETH.abi.json"
include_events:
- Transfer
chat:
opsgenie:
- api_key: ${OPSGENIE_API_KEY}
priority: P1networks
This is an array of networks you want to create OpsGenie alerts for.
...
contracts:
- name: RocketPoolETH
details:
- network: ethereum
address: "0xae78736cd615f374d3085123a210448e74fc6393"
start_block: "18600000"
end_block: "18600181"
abi: "./abis/RocketTokenRETH.abi.json"
include_events:
- Transfer
chat:
opsgenie:
- api_key: ${OPSGENIE_API_KEY}
priority: P1
networks:
- ethereummessages
This is an array of messages you want to create as OpsGenie alerts. 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:
opsgenie:
- api_key: ${OPSGENIE_API_KEY}
priority: P1
networks:
- ethereum
messages:
- event_name: Transferfilter_expression
This accepts a filter expression to filter the events before creating an OpsGenie alert.
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 creating an OpsGenie alert.
template_inline
You can then write your own template inline, this is the template used as the OpsGenie alert message.
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:
opsgenie:
- api_key: ${OPSGENIE_API_KEY}
priority: P1
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}}
"