Setting up Custom Events for disk utilization using the API

It is possible to create custom events in Instana to create Issues when disk space utilization is low.  It is not currently possible to do this using the Instana UI.  You need to use the Instana Open API (https://instana.github.io/openapi/).

The first thing you need to do is ensure that Instana is monitoring the File System you want to create the Event for.  Use the Host Dashboard for the Host in question and check the File Systems section. If the file system is listed, simply copy its name for use later.  If you do not see the File System listed, configure the Instana Agent to monitor the File System you need (Please refer to https://docs.instana.io/quick_start/agent_configuration/#additional-filesystems).  For our purposes here, we will assume Instana is already monitoring the File System.

You will need to use the "Update Custom Event Specification" API Endpoint (please see: https://instana.github.io/openapi/#operation/putCustomEventSpecification). The specific endpoint is PUT {{base}}/api/events/settings/event-specifications/custom/<ID> and you will need to provide a JSON document defining the Custom Event.

For example:

{
  "id": <ID>,
  "name": "<FILE SYSTEM NAME> Free Disk Space is Low",
  "entityType": "host",
  "query": "",
  "triggering": false,
  "description": "Free Disk for <FILE SYSTEM NAME> is under 10%",
  "expirationTime": 60000,
  "enabled": true,
  "rules": [
    {
      "ruleType": "threshold",
      "severity": 10,
      "metricName": <FILE SYSTEM METRIC>,
      "rollup": 0,
      "window": 10000,
      "aggregation" : "avg",
      "conditionOperator": ">=",
      "conditionValue": 0.9
    }
  ]
}

You will need to replace <ID> with a guid and <FILE SYSTEM NAME> with the name of the file system that you copy/pasted from the Host Dashboard.  <FILE SYSEM METRIC NAME> will be File System you copy/pasted from the Host Dashboard prepended with fs. and appended with .used.  For example, if the File System listed on the Host Dashboard is /dev/sda1, then the <FILE SYSTEM NAME> is /dev/sda1 and the <FILE SYSTEM METRIC> is fs./dev/sda1.used.

Feel free to change the other parameters (you can also change them after the Event is created in the UI).  For the <ID> you can use the "Summary of all built-in and custom event specifications" endpoint - {{base}}/api/events/settings/event-specifications/infos - to get a list of all currently configured Events and their ID's.  Simply increment an existing ID and use that (please see https://instana.github.io/openapi/#operation/getEventSpecificationInfos). Also, note that the ID has to be set in both the API endpoint and JSON body.

Here is an example with values filled in:

{
  "id": "2n9EJg8feV0xRMwL7c8URG0UoNc",
  "name": "/dev/sdb1 Free Disk Space is Low",
  "entityType": "host",
  "query": "",
  "triggering": false,
  "description": "Free Disk for /dev/sdb1 is under 10%",
  "expirationTime": 60000,
  "enabled": true,
  "rules": [
    {
      "ruleType": "threshold",
      "severity": 10,
      "metricName": "fs./dev/sdb1.used",
      "rollup": 0,
      "window": 10000,
      "aggregation" : "avg",
      "conditionOperator": ">=",
      "conditionValue": 0.9
  }
  ]
}

Once the Event has been created using the API, it will be visible in the Events screen in the UI like any other Custom Event - you will be able to change the parameters there (e.g. window size, aggregation, threshold, etc.).

Have more questions? Submit a request

Comments