API

Please note: This documentation is a work in progress and more detail is required.

Query using PromQL

Query using PromQL and returns JSON datapoints compatible with the Prometheus Grafana plugin.

URL

/api/v1/query_range

Method

GET

URL Params

Required

  • start=[time in RFC3339Nano]
  • end=[time in RFC3339Nano]
  • step=[time duration]
  • target=[string]

Optional

  • debug=[bool]
  • lookback=[string|time duration]: This sets the per request lookback duration to something other than the default set in config, can either be a time duration or the string “step” which sets the lookback to the same as the step request parameter.

Header Params

Optional

  • M3-Metrics-Type:
    If this header is set, it determines what type of metric to store this metric value as. Otherwise by default, metrics will be stored in all namespaces that are configured. You can also disable this default behavior by setting downsample options to all: false for a namespace in the coordinator config, for more see disabling automatic aggregation. Must be one of:
    unaggregated: Write metrics directly to configured unaggregated namespace.
    aggregated: Write metrics directly to a configured aggregated namespace (bypassing any aggregation), this requires the M3-Storage-Policy header to be set to resolve which namespace to write metrics to.
  • M3-Storage-Policy:
    If this header is set, it determines which aggregated namespace to read/write metrics directly to/from (bypassing any aggregation).
    The value of the header must be in the format of resolution:retention in duration shorthand. e.g. 1m:48h specifices 1 minute resolution and 48 hour retention. Valid time units are “ns”, “us” (or “µs”), “ms”, “s”, “m”, “h”. Here is an example of querying metrics from a specific namespace.

  • M3-Restrict-By-Tags-JSON:
    If this header is set it can ensure specific label matching is performed as part of every query including series metadata endpoints. As an example, the following header would unconditionally cause globaltag=somevalue to be a part of all queries issued regardless of if they include the label or not in a query and also strip the “globaltag” from appearing as a label in any of the resulting timeseries:

  1. M3-Restrict-By-Tags-JSON: '{"match":[{"name":"globaltag","type":"EQUAL","value":"somevalue"}],"strip":["globaltag"]}'
  • M3-Limit-Max-Series:
    If this header is set it will override any configured per query time series limit. If the limit is hit, it will either return a partial result or an error based on the require exhaustive configuration set.

  • M3-Limit-Max-Docs:
    If this header is set it will override any configured per query time series * blocks limit (docs limit). If the limit is hit, it will either return a partial result or an error based on the require exhaustive configuration set.

  • M3-Limit-Require-Exhaustive:
    If this header is set it will override any configured require exhaustive setting. If “true” it will return an error if query hits a configured limit (such as series or docs limit) instead of a partial result. Otherwise if “false” it will return a partial result of the time series already matched with the response header M3-Results-Limited detailing the limit that was hit and a warning included in the response body.

Data Params

None.

Sample Call

  1. curl 'http://localhost:7201/api/v1/query_range?query=abs(http_requests_total)&start=1530220860&end=1530220900&step=15s'
  2. {
  3. "status": "success",
  4. "data": {
  5. "resultType": "matrix",
  6. "result": [
  7. {
  8. "metric": {
  9. "code": "200",
  10. "handler": "graph",
  11. "method": "get"
  12. },
  13. "values": [
  14. [
  15. 1530220860,
  16. "6"
  17. ],
  18. [
  19. 1530220875,
  20. "6"
  21. ],
  22. [
  23. 1530220890,
  24. "6"
  25. ]
  26. ]
  27. },
  28. {
  29. "metric": {
  30. "code": "200",
  31. "handler": "label_values",
  32. "method": "get"
  33. },
  34. "values": [
  35. [
  36. 1530220860,
  37. "6"
  38. ],
  39. [
  40. 1530220875,
  41. "6"
  42. ],
  43. [
  44. 1530220890,
  45. "6"
  46. ]
  47. ]
  48. }
  49. ]
  50. }
  51. }