字段说明

支持创建 port proc log 三种采集策略 字段说明

  • nid:关联的对象树节点
  • name:采集名称
  • tags:采集额外上报的tags
  • step:探测的周期
  • comment:备注
  • port 独有字段
    • port:探测的端口端口号
    • timeout: 探测端口的超时时间,单位为秒
  • proc 独有字段
    • collect_method:进程采集方式有 cmd 和 name 两种
    • target:进程采集的目标,选cmd时为命令行,name时为进程名

log采集字段解释到日志监控页面查看

创建采集

POST /api/portal/collect

请求样例

  1. [
  2. {
  3. "type": "port",
  4. "data": {
  5. "nid": 2,
  6. "collect_type": "port",
  7. "name": "service.port",
  8. "tags": "",
  9. "port": 90,
  10. "timeout": 3,
  11. "step": 20,
  12. "comment": ""
  13. }
  14. },
  15. {
  16. "type": "proc",
  17. "data": {
  18. "nid": 2,
  19. "collect_type": "proc",
  20. "name": "service",
  21. "collect_method": "cmd",
  22. "target": "tsdb",
  23. "tags": "",
  24. "step": 20,
  25. "comment": ""
  26. }
  27. },
  28. {
  29. "type": "log",
  30. "data": {
  31. "nid": 2,
  32. "collect_type": "log",
  33. "func_type": "FLOW",
  34. "name": "LOG.aa",
  35. "func": "cnt",
  36. "unit": "次数",
  37. "file_path": "/home/xiaoju/alarm/log/DEBUG.log",
  38. "time_format": "dd/mmm/yyyy:HH:MM:SS",
  39. "step": 10,
  40. "pattern": "flush"
  41. }
  42. }
  43. ]

更新采集

PUT /api/portal/collect

请求样例

  1. //proc
  2. {
  3. "type": "proc",
  4. "data": {
  5. "id": 1,
  6. "nid": 2,
  7. "collect_type": "proc",
  8. "name": "444444444",
  9. "step": 20,
  10. "comment": "test",
  11. "target": "tsdb",
  12. "collect_method": "cmd"
  13. }
  14. }
  15. //port
  16. {
  17. "type": "port",
  18. "data": {
  19. "id": 1,
  20. "nid": 2,
  21. "collect_type": "port",
  22. "name": "33333",
  23. "step": 10,
  24. "comment": "bbbb2222aa",
  25. "port": 900,
  26. "timeout": 3
  27. }
  28. }
  29. //log
  30. {
  31. "type": "log",
  32. "data": {
  33. "nid": 2,
  34. "collect_type": "log",
  35. "func_type": "FLOW",
  36. "name": "LOG.aa",
  37. "func": "cnt",
  38. "unit": "次数",
  39. "file_path": "/home/xiaoju/alarm/log/DEBUG.log",
  40. "time_format": "dd/mmm/yyyy:HH:MM:SS",
  41. "step": 10,
  42. "pattern": "flush"
  43. }
  44. }

删除采集

DELETE /api/portal/collect

请求样例

  1. [
  2. {
  3. "type": "port",
  4. "ids": [1,2]
  5. },
  6. {
  7. "type": "proc",
  8. "ids": [1,2]
  9. }
  10. ]

查看采集策略列表

GET /api/portal/collect/list?nid=1&type=port

  • nid:关联的对象树节点id,选填
  • type:采集类型[proc,port,log]

返回样例

  1. {
  2. "dat": [
  3. {
  4. "id": 4,
  5. "nid": 2,
  6. "collect_type": "port",
  7. "name": "tsdb",
  8. "tags": "service=tsdb",
  9. "step": 10,
  10. "comment": "",
  11. "creator": "root",
  12. "created": "2019-09-03T18:24:02+08:00",
  13. "last_updator": "root",
  14. "last_updated": "2019-09-03T18:24:02+08:00",
  15. "port": 8046,
  16. "timeout": 3
  17. },
  18. {
  19. "id": 13,
  20. "nid": 2,
  21. "collect_type": "log",
  22. "name": "log.a",
  23. "step": 10,
  24. "comment": "",
  25. "creator": "root",
  26. "created": "2019-09-17T18:26:06+08:00",
  27. "last_updator": "root",
  28. "last_updated": "2019-09-17T18:26:06+08:00",
  29. "tags": null,
  30. "file_path": "a",
  31. "time_format": "dd/mmm/yyyy:HH:MM:SS",
  32. "pattern": "a",
  33. "func": "cnt",
  34. "func_type": "FLOW",
  35. "unit": "",
  36. "degree": 0,
  37. "zerofill": 0,
  38. }
  39. ],
  40. "err": ""
  41. }

查看单个采集策略

GET /api/portal/collect?type=proc&id=1

  • type:采集类型[proc,port,log]
  • id:采集策略id 返回样例
    1. {
    2. "dat": {
    3. "id": 3,
    4. "nid": 21,
    5. "collect_type": "port",
    6. "name": "monapi",
    7. "tags": "service=monapi",
    8. "step": 10,
    9. "comment": "",
    10. "creator": "root",
    11. "created": "2020-02-21T23:24:33+08:00",
    12. "last_updator": "root",
    13. "last_updated": "2020-02-21T23:24:33+08:00",
    14. "port": 8058,
    15. "timeout": 3
    16. },
    17. "err": ""
    18. }