Service metrics

Posting Service Metrics

This will transmit metrics tied to services to Mackerel.

POST /api/v0/services/<serviceName>/tsdb

If old values are being transmitted to the API, the values on the Mackerel interface will be overwritten. If posting with a timestamp older than 24 hours, those metrics will not be recorded (a status code 200 response will be returned). Additionally, an alert will not occur for an old value, even if a threshold is surpassed, since alerts occur based on the latest values from the Mackerel interface.

Required permissions for API key

  • Read
  • Write

Input

[ <metricValue>, <metricValue>, … ]

<metricValue> : an object that holds the following keys

KEY TYPE DESCRIPTION
name string metric name([a-zA-Z0-9._-]+
time number unix time
value number measured value at time

Response

Success

{
  "success": true
}

Error

STATUS CODE DESCRIPTION
403 when the API doesn't have the required permissions / when accessing from outside the permitted IP address range
429 When the number of requests per minute is exceeded. Correct this by setting the posting frequency to a 1 minute interval, or posting multiple metrics at once, etc.
other than 200 any error other than the above

Getting service metrics

This will get metric values connected to services.

GET /api/v0/services/<serviceName>/metrics

Required permissions for API key

  • Read

Input (Query parameter)

With the following parameter, the metric name and time span to be collected will be assigned.

KEY TYPE DESCRIPTION
name string metric name
from number the start of the time period you want metrics for (unix time)
to number the end of the time period you want metrics for (unix time)

Response

Success

{
  "metrics": [
    {
      "time": <time>,
      "value": <value>
    },
    {
      "time": <time>,
      "value": <value>
    },
    …
  }
}
  • response will be in chronological order
  • the <time> displayed will be in unix time

Error

STATUS CODE DESCRIPTION
404 when the service or metric doesn't exist
other than 200 any error other than the above