监控数据

本节讲解监控数据相关API

上报数据

Nightingale的transfer和collector两个模块都提供了上报数据的接口
本地collector上报接口 POST http://127.0.0.1:2058/api/collector/push
中心transfer上报接口 POST /api/transfer/push
字段含义见数据规范
说明一下 extra 字段,用户可以在这个字段中添加额外的信息,比如traceId,当监控数据触发告警后,告警引擎会将 extra 的内容写到告警事件中,透传给告警历史页面,用户可以根据 extra 中的信息更快的定位问题

请求样例

  1. [
  2. {
  3. "metric":"cpu.util",
  4. "endpoint":"192.168.1.2",
  5. "timestamp":1559733442,
  6. "step":10,
  7. "value":1,
  8. "tags":"",
  9. "extra":""
  10. }
  11. ]

查询metric

POST /api/index/metrics

请求样例

  1. {
  2. "endpoints": ["host1","host2"]
  3. }

返回样例

  1. {
  2. "dat": [
  3. {
  4. "metrics": [
  5. "cpu.idle"
  6. ],
  7. }
  8. ],
  9. "err": "",
  10. }

查询tags

POST /api/index/tagkv

请求样例

  1. {
  2. "endpoints": ["host1","host2"],
  3. "metrics": ["disk.used.percent"],
  4. }

返回样例

  1. {
  2. "dat": [
  3. {
  4. "endpoints": ["host1","host2"],
  5. "metric": "disk.used.percent",
  6. "tagkv": [
  7. {
  8. "tagk": "mount",
  9. "tagv": ["/", "/home"]
  10. },
  11. ]
  12. }
  13. ],
  14. "err":""
  15. }

查询监控数据

POST /api/transfer/data

请求样例

  1. [
  2. {
  3. "start": 1598338900,
  4. "end": 1598338940,
  5. "endpoints": ["10.254.226.221"],
  6. "counters": ["cpu.idle"],
  7. "step": 20,
  8. "dstype": "GAUGE"
  9. },
  10. {
  11. "start": 1598338900,
  12. "end": 1598338940,
  13. "endpoints": ["10.254.88.96"],
  14. "counters": ["disk.bytes.used.percent/mount=/"],
  15. "step": 20,
  16. "dstype": "GAUGE"
  17. }
  18. ]

返回样例

  1. {
  2. "dat": [
  3. {
  4. "start": 1598338900,
  5. "end": 1598338940,
  6. "endpoint": "10.254.226.221",
  7. "counter": "cpu.idle",
  8. "dstype": "GAUGE",
  9. "step": 20,
  10. "values": [
  11. {
  12. "timestamp": 1598338900,
  13. "value": 98.648649
  14. },
  15. {
  16. "timestamp": 1598338920,
  17. "value": 98.316498
  18. },
  19. {
  20. "timestamp": 1598338940,
  21. "value": 98.307953
  22. }
  23. ]
  24. },
  25. {
  26. "start": 1598338900,
  27. "end": 1598338940,
  28. "endpoint": "10.254.88.96",
  29. "counter": "disk.bytes.used.percent/mount=/",
  30. "dstype": "GAUGE",
  31. "step": 20,
  32. "values": [
  33. {
  34. "timestamp": 1598338900,
  35. "value": 14.636725
  36. },
  37. {
  38. "timestamp": 1598338920,
  39. "value": 14.636725
  40. },
  41. {
  42. "timestamp": 1598338940,
  43. "value": 14.63682
  44. }
  45. ]
  46. }
  47. ],
  48. "err": ""
  49. }