Agentless monitoring and custom metrics

You can use our API to post data to us without needing the agent. This is useful if you want to include metric collection in your own scripts and use the Server Density graphs, dashboard and alerting to store the data.

Using the alerts/postback API method you can send back data as if you were the monitoring agent. You can also send back any custom metrics you like too. For example, the following will send system.load.1, my.custom.metric & my.custom.metric.count as gauge metrics with the tag key:value

curl -X POST "https://api.serverdensity.io/alerts/postbacks?token=b97da80a41c4f61bff05975ee51eb1aa" \
   --data hash=12442a69ad6629a5942d56c126d3205b \
   --data payload='{"agentKey":"23ddab267dff7cde05dc20a28e93c272","agentVersion" : "2.0", "sdAgentVersion": 2.0, "metrics":[["system.load.1",1526312932,8,{"hostname":"example.com","type":"gauge","tags":["key:value"]}],["my.custom.metric",1526312932,1,{"hostname":"example.com","type":"gauge","tags":["key:value"]}],["my.custom.metric.count",1526312932,2,{"hostname":"example.com","type":"gauge","tags":["key:value"]}]]}' \
   --header "X-Forwarded-Host: YOURACCOUNT.serverdensity.io"

Note: replace the X-Forward-Host header with your real account URL, using .io and not .com

The metrics are defined in a metric list and each metric is a list too. The order of the values in the list is important as this defines the values of the metric attributes when processed by Server Density. For clarity, the list is pretty printed below: 

 "metrics": [
  [
    "system.load.1", # Metric name
    1526312932,      # Metric timestamp as an epoch
    8,               # Metric value (used for graphing and alerting) 
    {
      "hostname": "example.com", # Hostname of device of metric
      "type": "gauge",           # Metric type
      "tags": [                  # List of tags to be associated with the metric. Not required
        "key:value"              # Tags must be in key:value format else they will be ignored
      ]
    }
  ],
  [
    "my.custom.metric",
    1526312932,
    1,
    {
      "hostname": "example.com",
      "type": "gauge",
      "tags": [
        "key:value"
      ]
    }
  ],
  [
    "my.custom.metric.count",
    1526312932,
    2,
    {
      "hostname": "example.com",
      "type": "gauge",
      "tags": [
        "mode:standalone"
      ]
    }
  ],
]

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Monday  —  Friday.

10am  —  6pm UK.

Dedicated Support.