Curl example to create a custom rule via Instana REST API

Problem:

I need to create a custom rule via the Instana REST API. How can I do this?

Solution:

The custom rules can be created using the REST API. Below is an example to show how this can be done via a simple curl command to set a rule for cpu.used metric for a host:

1. Create an API token under Access Control > API Tokens, with at least "Configuration of custom alerts" enabled
2. Befor you use the below curl command in your terminal, you need to replace:

- {UNIT}-{TENANT} with your unit-tenant

- RULE_ID with any ID you like (e.g random numbers), but make sure to use the same number in the "url" and "id" field

- API_TOKEN with the token you just created in step 1

- You can alter the entityType, metricName etc as per your requirement 

 

curl --request PUT --url 'https://{UNIT}-{TENANT}.instana.io/api/rules/RULE_ID' --header 'Authorization: apiToken API_TOKEN --header 'Content-Type: application/json' --data '{"id":"RULE_ID","name":"Rule for cpu usage","entityType":"host","metricName":"cpu.used","rollup":1000,"window":60000,"aggregation":"avg","conditionOperator":">=","conditionValue":10.0}'

 

 

Have more questions? Submit a request

Comments