GET /api/v1/alarm/events Get events list from one event case

  • Session Required
  • 支援GET && POST
  • GET: “/api/v1/alarm/events?startTime=1466956800&endTime=1480521600”
  • POST: form post & json body post 皆可以使用
  • 用于储存每一次的告警历史, 触发及恢复时机点
  • 参数:
  • startTime: 开始区间
  • endTime: 结束区间
  • status: 系统判定告警状态 [0, 1] 0表触发, 1表恢复
  • event_id: 某一单向告警id [拿取单笔告告警状态]
  • limit: 设定笔数返回上线 [预设及最大上线值:50]
  • page: 后端分页页数

Request

{ startTime: 1466956800, endTime: 1480521600, status: 0, event_id: "s_165_cef145900bf4e2a4a0db8b85762b9cdb", limit: 50, page: 1 }

Response

Status: 200 [ { "id": 635166, "event_caseId": "s_165_cef145900bf4e2a4a0db8b85762b9cdb", "step": 0, "cond": "10.649350649350648 != 66", "status": 0, "timestamp": "2016-06-23T04:55:00+08:00" }, { "id": 635149, "event_caseId": "s_165_cef145900bf4e2a4a0db8b85762b9cdb", "step": 0, "cond": "13.486005089058525 != 66", "status": 0, "timestamp": "2016-06-23T04:50:00+08:00" } ]

For more example, see the alarm.html

GET /api/v1/alarm/event_note Get status note of event case

  • Session Required
  • 使用者可以对告警留言并人工切换状态
  • 参数:
  • startTime: 开始区间
  • endTime: 结束区间
  • status: 人工判定告警状态 [“in progress”, “unresolved”, “resolved”, “ignored”, “comment”]
  • event_id: 某一单向告警id
  • limit: 设定笔数返回上线 [预设及最大上线值:50]
  • page: 后端分页页数

Request

/api/v1/alarm/event_note?startTime=1466956800&endTime=1480521600&event_id=s_165_cef145900bf4e2a4a0db8b85762b9cdb&status=ignored

Response

Status: 200 [ { "event_caseId": "s_165_cef145900bf4e2a4a0db8b85762b9cdb", "note": "test", "case_id": "", "status": "ignored", "timestamp": "2016-06-23T05:39:09+08:00", "user": "root" }, { "event_caseId": "s_165_9d223f126e7ecb3477cd6806f1ee9656", "note": "Ignored by user", "case_id": "", "status": "ignored", "timestamp": "2016-06-23T05:38:56+08:00", "user": "root" } ]

For more example, see the alarm.html

POST /api/v1/alarm/event_note Add status note to a event case

  • Session Required
  • 使用者可以对告警留言并人工切换状态
  • 参数:
  • event_id: 某一单向告警id
  • status: 人工判定告警状态 [“in progress”, “unresolved”, “resolved”, “ignored”, “comment”], comment之外的留言会改变event_case的process_status状态
  • note: 对于告警留言
  • case_id: 填入外部对应的系统公单号

Request

{ "event_id": "s_165_cef145900bf4e2a4a0db8b85762b9cdb", "note": "closed case", "case_id": "k00001", "status": "resolved" }

Response

Status: 200 { "id": "s_165_cef145900bf4e2a4a0db8b85762b9cdb", "message": "add note to s_165_cef145900bf4e2a4a0db8b85762b9cdb successfuled" }

For more example, see the alarm.html

GET /api/v1/alarm/eventcases Get event cases list

  • Session Required
  • 支援GET && POST
  • GET: “/api/v1/alarm/eventcases?startTime=1466956800&endTime=1480521600”
  • POST: form post & json body post 皆可以使用
  • 一个告警设置只会产生一个eventcases, 每一次的告警历史会储存于events中
  • 参数:
  • startTime: 开始区间
  • endTime: 结束区间
  • priority: 优先等级 [0 ~ 4]
  • status: 系统判定告警状态 [“OK”, “PROBLEM”] *逗号分隔支援多笔查询
  • process_status: 人工判定告警状态 [“in progress”, “unresolved”, “resolved”, “ignored”] *逗号分隔支援多笔查询
  • metrics: 告警监控项搜寻 [regexp搜寻]
  • event_id: 某一单向告警id [拿取单笔告告警状态]
  • limit: 设定笔数返回上线, 如果搭配page一起使用表示单页的上线,如果page无设定表示单页返回上线. [预设及最大上线值 => 页面: 50 / 单页: 2000]
  • page: 后端分页页数

Request

{ startTime: 1466956800, endTime: 1480521600, priority: 0, status: "OK,PROBLEM", process_status: "unresolved", metrics: "cpu.+", event_id: "s_165_cef145900bf4e2a4a0db8b85762b9cdb", limit: 50, page: 1 }

Response

Status: 200 [ { "id": "s_46_1ac45122afb893adc02fbd30154ac303", "endpoint": "agent4", "metric": "cpu.iowait", "func": "all(#3)", "cond": "48.33759590792839 > 40", "note": "CPU I/O wait超过40", "step": 1, "current_step": 1, "priority": 1, "status": "PROBLEM", "timestamp": "2016-08-01T06:25:00+08:00", "update_at": "2016-08-01T06:25:00+08:00", "closed_at": null, "closed_note": "", "user_modified": 0, "tpl_creator": "root", "expression_id": 0, "strategy_id": 46, "template_id": 126, "process_note": 16907, "process_status": "ignored" }, { "id": "s_50_6438ac68b30e2712fb8f00d894c46e21", "endpoint": "agent5", "metric": "cpu.idle", "func": "avg(#3)", "cond": "95.16331658291456 <= 98", "note": "cpu空闲值报警", "step": 1, "current_step": 1, "priority": 3, "status": "PROBLEM", "timestamp": "2016-07-03T16:13:00+08:00", "update_at": "2016-07-03T16:13:00+08:00", "closed_at": null, "closed_note": "", "user_modified": 0, "tpl_creator": "root", "expression_id": 0, "strategy_id": 50, "template_id": 53, "process_note": 1181, "process_status": "ignored" } ]

For more example, see the alarm.html

PUT /api/v1/user/update Update User

更新使用者

Request

{ "name": "test1", "cnname": "翱鶚Test", "email": "root123@cepave.com", "im": "44955834958", "phone": "99999999999", "qq": "904394234239" }

Response

Status: 200 {"message":"user info updated"}

For more example, see the user.

For errors responses, see the response status codes documentation.

For more example, see the user.html

GET /api/v1/user/logout Logout

使用者登出

Response

Sends back a collection of things.

Status: 200 {"message":"logout successful"}

For more example, see the user.

For errors responses, see the response status codes documentation.

For more example, see the user.html

POST /api/v1/user/login Login

使用者登入

Request

{ "name": "test2", "password": "test2" }

Response

Status: 200 { "sig": "9d791331c0ea11e690c5001500c6ca5a", "name": "test2", "admin": false }

For more example, see the user.

For errors responses, see the response status codes documentation.

For more example, see the user.html

GET /api/v1/user/users User List

Response

Status: 200 [ { "id": 1, "name": "root", "cnname": "", "email": "", "phone": "", "im": "", "qq": "904394234239", "role": 2 }, { "id": 32, "name": "owltester", "cnname": "翱鶚", "email": "root123@cepave.com", "phone": "99999999999", "im": "44955834958", "qq": "904394234239", "role": 0 } ]

For more example, see the user.

For errors responses, see the response status codes documentation.

For more example, see the user.html

GET /api/v1/user/u/#{user_id} Get User info by id

  • Session Required
  • Admin usage
  • ex. /api/v1/user/u/4

Response

Status: 200 { "id": 4, "name": "userA", "cnname": "tear", "email": "", "phone": "", "im": "", "qq": "", "role": 0 }

For more example, see the user.

For errors responses, see the response status codes documentation.

For more example, see the user.html

GET /api/v1/user/current Current User info

  • Session Required
  • 当前使用者资讯

Response

Status: 200 { "id": 2, "name": "root", "cnname": "", "email": "", "phone": "", "im": "", "qq": "", "role": 2 }

For more example, see the user.

For errors responses, see the response status codes documentation.

For more example, see the user.html

POST /api/v1/user/create Create User

Request

{"name": "test","password": "test", "email":"xxx@xxx.com", "cnname": "翱鹗"}

Response

Status: 200 { "name": "owltester", "password": "mypassword", "cnname": "翱鹗", "email": "root123@cepave.com", "im": "44955834958", "phone": "99999999999", "qq": "904394234239" }

For more example, see the user.

For errors responses, see the response status codes documentation.

For more example, see the user.html

PUT /api/v1/user/cgpasswd Change Password

Request

{ "new_password": "test1", "old_password": "test1" }

Response

Status: 200 {"message":"password updated!"}

For more example, see the user.html

PUT /api/v1/template/ Update Template

  • Session Required
  • parent_id: 继承现有Template

Request

{ "tpl_id": 225, "parent_id": 0, "name": "AtmpForTesting2" }

Response

Status: 200 {"message":"template updated"}

For more example, see the template.html

GET /api/v1/template/ Template List

Template List

Response

Status: 200 [ { "id": 1, "tpl_name": "cpu.board", "parent_id": 0, "action_id": 5, "create_user": "usera" }, { "id": 2, "tpl_name": "traffic checking", "parent_id": 0, "action_id": 6, "create_user": "userb" }, { "id": 3, "tpl_name": "cputest", "parent_id": 0, "action_id": 7, "create_user": "userc" }, { "id": 5, "tpl_name": "all metrics base", "parent_id": 0, "action_id": 12, "create_user": "root" } ]

For more example, see the template.html

GET /api/v1/template/#{template_id} Get Template Info by id

  • Session Required
  • ex. /api/v1/template/178

Response

Status: 200 { "action": { "id": 141, "uic": "admin,mm1", "url": "", "callback": 0, "before_callback_sms": 0, "before_callback_mail": 0, "after_callback_sms": 0, "after_callback_mail": 0 }, "stratges": [ { "id": 686, "metric": "xxx.check", "tags": "name=xxx", "max_step": 3, "priority": 2, "func": "all(#2)", "op": "<", "right_value": "1", "note": "xxx服务异常", "run_begin": "", "run_end": "", "tpl_id": 178 }, { "id": 687, "metric": "xxx.sync", "tags": "", "max_step": 3, "priority": 2, "func": "all(#3)", "op": "!=", "right_value": "0", "note": "XXX同步异常", "run_begin": "", "run_end": "", "tpl_id": 178 }, { "id": 688, "metric": "bbb.check.mq", "tags": "", "max_step": 3, "priority": 2, "func": "all(#3)", "op": "==", "right_value": "1", "note": "bbb连接MQ异常", "run_begin": "", "run_end": "", "tpl_id": 178 }, { "id": 793, "metric": "aaa.proc.num", "tags": "", "max_step": 3, "priority": 2, "func": "all(#3)", "op": "==", "right_value": "1", "note": "aaaa 进程大于5", "run_begin": "", "run_end": "", "tpl_id": 178 } ], "template": { "id": 178, "tpl_name": "TemplateA", "parent_id": 0, "action_id": 141, "create_user": "root" } }

For more example, see the template.html

DELETE /api/v1/template/#{template_id} Delete Template

Delete a Template

  • Session Required
  • ex. /api/v1/template/225

Response

Status: 200 {"message":"template 225 has been deleted"}

For more example, see the template.html

POST /api/v1/template/ Create Template

  • Session Required
  • parent_id: 继承现有Template

Request

{"parent_id":0,"name":"AtmpForTesting"}

Response

Status: 200 {"message":"template created"}

For more example, see the template.html

PUT /api/v1/template/action Update Template Action

Update Action

  • Session Required
  • params:
    • url: callback url
    • uic: 需要通知的使用者群组(name)
    • callback: enable/disable

Request

{ "url": "", "uic": "test,tt2,tt3", "id": 175, "callback": 1, "before_callback_sms": 0, "before_callback_mail": 0, "after_callback_sms": 0, "after_callback_mail": 0 }

Response

Status: 200 {"message":"action is updated, row affected: 1"}

For more example, see the template.html

POST /api/v1/template/action Create Template Action

Create Action to a Template

  • Session Required
  • params:
    • url: callback url
    • uic: 需要通知的使用者群组(name)
    • callback: enable/disable

Request

{ "url": "", "uic": "test,tt2", "tpl_id": 225, "callback": 1, "before_callback_sms": 0, "before_callback_mail": 0, "after_callback_sms": 0, "after_callback_mail": 0 }

Response

Status: 200 {"message":"template created"}

For more example, see the template.html

PUT /api/v1/team Team Update

更新使用者群組

  • Session Required
  • users: 属於该群组的user id list
  • resume: team的描述
  • 除Admin外, 使用者只能更新自己创建的team

Request

{ "team_id": 107, "resume": "i'm descript update", "users": [4,5,6,7] }

Response

Status: 200 {"message":"team updated!"}

For more example, see the team.html

GET /api/v1/team Team List

  • Session Required
  • q: 使用 regex 查询字符, 查询team name
    • option 参数

Request

q=a.+

Response

Status: 200 [ { "id": 1, "name": "a", "resume": "", "creator": 1 }, { "id": 5, "name": "atestteam", "resume": "i'm test", "creator": 16 }, { "id": 107, "name": "ateamname", "resume": "i'm descript", "creator": 1 } ]

For more example, see the team.html

GET /api/v1/team/#{team_id} Get Team Info By Id

  • Session Required
  • ex. /api/v1/team/107

Response

Status: 200 { "id": 107, "name": "ateamname", "resume": "i'm descript", "creator": 1, "users": [ { "id": 4, "name": "test1", "cnname": "翱鶚Test", "email": "root123@cepave.com", "phone": "99999999999", "im": "44955834958", "qq": "904394234239", "role": 0 }, { "id": 7, "name": "cepave1", "cnname": "", "email": "", "phone": "", "im": "", "qq": "904394234239", "role": 0 } ] }

For more example, see the team.html

DELETE /api/v1/team/#{team_id} Delete Team By Id

新增使用者群組

  • Session Required
  • ex. /api/v1/team/107
  • 除Admin外, 使用者只能更新自己创建的team

Response

Status: 200 {"message":"team 107 is deleted. Affect row: 1 / refer delete: 4"}

For more example, see the team.html

POST /api/v1/team Team Create

新增使用者群組

  • Session Required
  • users: 属於该群组的user id list
  • resume: team的描述

Request

{"team_name": "ateamname","resume": "i'm descript", "users": [1]}

Response

Status: 200 {"message":"team created! Afftect row: 1, Affect refer: 1"}

For more example, see the team.html

PUT /api/v1/strategy Update Strategy

Request

{ "tags": "", "run_end": "", "run_begin": "", "right_value": "1", "priority": 2, "op": "==", "note": "this is a test", "metric": "agent.alive", "max_step": 3, "id": 904, "func": "all(#3)" }

Response

Status: 200 {"message":"stragtegy:904 has been updated"}

For more example, see the template.html

GET /api/v1/strategy Get Strategy List

Response

Status: 200 [ { "id": 893, "metric": "process.num", "tags": "name=redis", "max_step": 3, "priority": 2, "func": "all(#2)", "op": "<", "right_value": "1", "note": "Redis异常", "run_begin": "", "run_end": "", "tpl_id": 221 }, { "id": 894, "metric": "process.num", "tags": "name=smtp", "max_step": 3, "priority": 2, "func": "all(#3)", "op": "<", "right_value": "1", "note": "Smtp异常", "run_begin": "", "run_end": "", "tpl_id": 221 }, { "id": 895, "metric": "process.num", "tags": "cmdline=logger", "max_step": 3, "priority": 3, "func": "all(#5)", "op": "<", "right_value": "2", "note": "logger异常", "run_begin": "", "run_end": "", "tpl_id": 221 }, ]

For more example, see the template.html

GET /api/v1/strategy/#{strategy_id} Get Strategy info by id

  • Session Required
  • ex. /api/v1/strategy/904

Response

Status: 200 { "id": 904, "metric": "agent.alive", "tags": "", "max_step": 3, "priority": 1, "func": "all(#3)", "op": "==", "right_value": "1", "note": "this is a test", "run_begin": "00:00", "run_end": "24:00", "tpl_id": 221 }

For more example, see the template.html

DELETE /api/v1/strategy/#{strategy_id} Delete Strategy

  • Session Required
  • ex. /api/v1/strategy/904

Response

Status: 200 {"message":"strategy:904 has been deleted"}

For more example, see the template.html

POST /api/v1/strategy Create Strategy

Request

{ "tpl_id": 221, "tags": "", "run_end": "24:00", "run_begin": "00:00", "right_value": "1", "priority": 1, "op": "==", "note": "this is a test", "metric": "agent.alive", "max_step": 3, "func": "all(#3)" }

Response

Status: 200 {"message":"stragtegy created"}

For more example, see the template.html

GET /api/v1/metric/tmplist Get Metric List

  • Session Required
  • Metric Suggestion for create strategy
  • base on ./data/metric file

Response

Status: 200 [ "cpu.busy", "cpu.cnt", "cpu.guest", "cpu.idle", "cpu.iowait", "cpu.irq", "cpu.nice", "cpu.softirq", "cpu.steal", "cpu.system", "cpu.user", "df.bytes.free", "df.bytes.free.percent" .... ]

For more example, see the template.html

GET /api/v1/dashboard/graph/:id Get graph by id

Request

/api/v1/dashboard/graph/4913

Response

Status: 200

{
  "counters": [
    "c1",
    "c2"
  ],
  "endpoints": [
    "a",
    "b"
  ],
  "falcon_tags": "",
  "graph_id": 4913,
  "graph_type": "h",
  "method": "",
  "position": 0,
  "screen_id": 1270,
  "timespan": 3600,
  "title": "no exist"
}
For more example, see the owl_scren_graph.html

DELETE /api/v1/dashboard/graph/:id Delete graph by id

Request

/api/v1/dashboard/graph/4913

Response

Status: 200

{"id":4913}
  • return created graph id
For more example, see the owl_scren_graph.html

POST /api/v1/dashboard/graph_new_screen Create a new screen and bind graph

  • Session Required
  • screen_name
    • string [required]
  • title
    • string [required]
    • name of graph
  • endpoints
    • []string [required]
  • counters
    • []string [required]
  • timespan
    • int64
    • 时间区段 (秒)
      • default 3600
  • graph_type
    • string [required]
    • 视角: h (endpoint view), k (counter view), a (combo view)
    • accept values:
      • h
      • a
      • k
  • method
    • string
    • accept values:
      • SUM
      • 空值
  • position
    • int64
    • 排序
      • 预设值為0
  • falcon_tags
    • string
    • owl-light not this concept, keep empty. (open-falcon only)

Request

{
  "title": "graphtitle",
  "screen_name": "newscreen",
  "endpoints": ["a","b"],
  "counters":["c1","c2"],
  "graph_type": 'h'
}

Response

Status: 200

{"id":4913, "screen_id": }
  • return created graph id
For more example, see the owl_scren_graph.html

POST /api/v1/dashboard/graph Create a graph and bind to exist screen

  • Session Required
  • screen_id
    • int64 [required]
  • title
    • string [required]
    • name of graph
  • endpoints
    • []string [required]
  • counters
    • []string [required]
  • timespan
    • int64
    • 时间区段 (秒)
      • default 3600
  • graph_type
    • string [required]
    • 视角: h (endpoint view), k (counter view), a (combo view)
    • accept values:
      • h
      • a
      • k
  • method
    • string
    • accept values:
      • SUM
      • 空值
  • position
    • int64
    • 排序
      • 预设值為0
  • falcon_tags
    • string
    • owl-light not this concept, keep empty. (open-falcon only)

Request

{
  "title": "imtitle",
  "screen_id": 1266,
  "endpoints": ["a-host","b-host"],
  "counters": ["c.1","c.2"],
  "graph_type": 'h'
}

Response

Status: 200

{"id":4912}
  • return created graph id
For more example, see the owl_scren_graph.html

PUT /api/v1/dashboard/screens Update Screen

  • Session Required
  • id
    • required
  • name
    • required
    • name must be unique, if exist will response error message to client

Request

{"name":"updaredscreen","id":1268}

Response

Status: 200

{"message":"ok"}
For more example, see the owl_screen.html

GET /api/v1/dashboard/screen/:id Get Screen by id

Request

/api/v1/dashboard/screen/1268

Response

Status: 200

{
  "graphs": [
    {
      "counters": [
        "c1",
        "c2"
      ],
      "endpoints": [
        "a",
        "b"
      ],
      "falcon_tags": "",
      "graph_id": 4917,
      "graph_type": "h",
      "method": "",
      "position": 0,
      "screen_id": 1274,
      "timespan": 3600,
      "title": "grep_demo"
    }
  ],
  "scren": {
    "id": 1274,
    "pid": 0,
    "name": "screen_test2"
  }
}
For more example, see the owl_screen.html

GET /api/v1/dashboard/screens Get Screen List

  • Session Required
  • limit
  • page
  • desc
    • value: true or false
    • Order by desc on id
  • key_word
    • search key words of screen name

Request

/api/v1/screens?limit=10&page=1&desc=true&key_word=test

Response

Status: 200

{
  "current_page": 1,
  "data": [
    {
      "graph_names": [],
      "id": 962,
      "pid": 0,
      "name": "FCM",
      "creator": "root"
    },
    {
      "graph_names": [
        "net.if.total.bytes",
        "net.if.total.bytes"
      ],
      "id": 965,
      "pid": 962,
      "name": "net.if.total.bytes",
      "creator": "root"
    },
    {
      "graph_names": [],
      "id": 967,
      "pid": 0,
      "name": "c01.i36",
      "creator": "root"
    },
    {
      "graph_names": [
        "cpu",
        "mysql_test",
        "cpu-1"
      ],
      "id": 968,
      "pid": 967,
      "name": "cpu",
      "creator": "root"
    },
    {
      "graph_names": [
        "cpu"
      ],
      "id": 969,
      "pid": 962,
      "name": "cpu",
      "creator": "root"
    },
    {
      "graph_names": [
        "net.if.total.bytes"
      ],
      "id": 970,
      "pid": 967,
      "name": "net.if.total.bytes",
      "creator": "root"
    },
    {
      "graph_names": [
        "mem"
      ],
      "id": 971,
      "pid": 967,
      "name": "mem",
      "creator": "root"
    },
    {
      "graph_names": [
        "mem"
      ],
      "id": 972,
      "pid": 962,
      "name": "mem",
      "creator": "root"
    },
    {
      "graph_names": [
        "cpu.load"
      ],
      "id": 973,
      "pid": 962,
      "name": "cpu.load",
      "creator": "root"
    },
    {
      "graph_names": [
        "cpu.load"
      ],
      "id": 975,
      "pid": 967,
      "name": "cpu.load",
      "creator": "root"
    }
  ],
  "desc_order": false,
  "key_word": "",
  "order_by": "id",
  "totall_count": 123,
  "totall_page": 13
}
For more example, see the owl_screen.html

DELETE /api/v1/dashboard/screen/:id Delete Screen by id

Request

/api/v1/screen/1268

Response

Status: 200

{
  "deleted_rows": 1,
  "deleted_graph_ids": [
    4901
  ],
  "message": "ok"
}
For more example, see the owl_screen.html

POST /api/v1/dashboard/screens Create Screen

  • Session Required
  • name
    • required
    • name must be unique, if exist will response error message to client
  • pid
    • option
    • parent id [Inherit]
    • owl-light don’t have this concept. this only for open-falcon

Request

{"pid":0,"name":"screen_test2"}

Response

Status: 200

{"id":1268,"pid":0,"name":"screen_test2"}
For more example, see the owl_screen.html

GET /api/v1/hostgroup/#{hostgroup_id}/plugins Get Plugin List of HostGroup

  • Session Required
  • ex. /api/v1/hostgroup/343/plugins
  • grp_id: hostgroup id

Response

Status: 200 [ { "id": 1499, "grp_id": 343, "dir": "testpath", "create_user": "root" }, { "id": 1501, "grp_id": 343, "dir": "testpath", "create_user": "root" } ]

For more example, see the plugin.html

DELETE /api/v1/plugin/#{plugin_id} Delete Plugin

  • Session Required
  • ex. /api/v1/plugin/1501

Response

Status: 200 {"message":"plugin:1501 is deleted"}

For more example, see the plugin.html

POST /api/v1/plugin Create A Plugin of HostGroup

  • Session Required
  • grp_id: hostgroup id

Request

{ "hostgroup_id": 343, "dir_path": "testpath" }

Response

Status: 200 { "id": 1501, "grp_id": 343, "dir": "testpath", "create_user": "root" }

For more example, see the plugin.html

PUT /api/v1/nodata/ Update Nodata

Request

{ "tags": "", "step": 60, "obj_type": "host", "obj": "docker-agent", "mock": -2, "metric": "test.metric", "id": 4, "dstype": "GAUGE" }

Response

Status: 200 { "id": 0, "name": "", "obj": "docker-agent", "obj_type": "host", "metric": "test.metric", "tags": "", "dstype": "GAUGE", "step": 60, "mock": -2, "creator": "" }

For more example, see the nodata.html

GET /api/v1/nodata Nodata List

Response

Status: 200 [ { "id": 2, "name": "owl_nodate", "obj": "docker-agent", "obj_type": "host", "metric": "test.metric", "tags": "", "dstype": "GAUGE", "step": 60, "mock": -2, "creator": "root" } ]

For more example, see the nodata.html

GET /api/v1/nodata/#{nodata_id} Get Nodata Info by id

  • Session Required
  • ex. /api/v1/nodata/2

Response

Status: 200 { "id": 2, "name": "owl_nodate", "obj": "docker-agent", "obj_type": "host", "metric": "test.metric", "tags": "", "dstype": "GAUGE", "step": 60, "mock": -2, "creator": "root" }

For more example, see the nodata.html

DELETE /api/v1/nodata/#{nodata_id} Delete Nodata

  • Session Required
  • ex. /api/v1/nodata/4

Response

Status: 200 {"message":"mockcfg:4 is deleted"}

For more example, see the nodata.html

POST /api/v1/nodata/ Create Nodata

Request

{ "tags": "", "step": 60, "obj_type": "host", "obj": "docker-agent", "name": "testnodata", "mock": -1, "metric": "test.metric", "dstype": "GAUGE" }

Response

Status: 200 { "id": 4, "name": "testnodata", "obj": "docker-agent", "obj_type": "host", "metric": "test.metric", "tags": "", "dstype": "GAUGE", "step": 60, "mock": -1, "creator": "root" }

For more example, see the nodata.html

PUT /api/v1/hostgroup/host Unbind a Host on HostGroup

  • Session Required
  • 如果使用者不是 Admin 只能对创建的hostgroup做操作

Request

{ "hostgroup_id": 343, "host_id": 9312 }

Response

Status: 200 {"message":"unbind host:9312 of hostgroup: 343"}

For more example, see the hostgroup.html

PUT /api/v1/hostgroup/template Unbind A Template of A HostGroup

Request

{ "tpl_id": 5, "grp_id": 3 }

Response

Status: 200 {"message":"template: 5 is unbind of HostGroup: 3"}

For more example, see the hostgroup.html

GET /api/v1/hostgroup/#{hostgroup_id}/template Get Template List of HostGroup

  • Session Required
  • ex. /api/v1/hostgroup/3/template

Response

Status: 200 { "hostgroup": { "id": 3, "grp_name": "hostgroupA", "create_user": "root" }, "templates": [ { "id": 5, "tpl_name": "TplA", "parent_id": 0, "action_id": 12, "create_user": "root" }, { "id": 91, "tpl_name": "TplB", "parent_id": 0, "action_id": 59, "create_user": "userA" }, { "id": 94, "tpl_name": "TplB", "parent_id": 0, "action_id": 62, "create_user": "userA" }, { "id": 103, "tpl_name": "TplC", "parent_id": 0, "action_id": 74, "create_user": "root" }, { "id": 104, "tpl_name": "TplD", "parent_id": 0, "action_id": 75, "create_user": "root" }, { "id": 105, "tpl_name": "TplE", "parent_id": 0, "action_id": 76, "create_user": "root" }, { "id": 116, "tpl_name": "TplG", "parent_id": 0, "action_id": 87, "create_user": "root" }, { "id": 125, "tpl_name": "TplH", "parent_id": 0, "action_id": 99, "create_user": "root" }, { "id": 126, "tpl_name": "http", "parent_id": 0, "action_id": 100, "create_user": "root" }, { "id": 127, "tpl_name": "TplJ", "parent_id": 0, "action_id": 101, "create_user": "root" } ] }

For more example, see the hostgroup.html

POST /api/v1/hostgroup/template Bind A Template to HostGroup

Request

{ "tpl_id": 5, "grp_id": 3 }

Response

Status: 200 {"grp_id":3,"tpl_id":5,"bind_user":2}

For more example, see the hostgroup.html

GET /api/v1/hostgroup/ HostGroup List

Response

Status: 200 [ { "id": 3, "grp_name": "docker-A", "create_user": "user-A" }, { "id": 5, "grp_name": "docker-T", "create_user": "user-B" }, { "id": 8, "grp_name": "docker-F", "create_user": "root" } ]

For more example, see the hostgroup.html

GET /api/v1/hostgroup/#{hostgroup_id} Get HostGroup info by id

  • Session Required
  • ex. /api/v1/hostgroup/343

Response

Status: 200 { "hostgroup": { "id": 343, "grp_name": "testhostgroup", "create_user": "root" }, "hosts": [ { "id": 9313, "hostname": "agent_test", "ip": "", "agent_version": "", "plugin_version": "", "maintain_begin": 0, "maintain_end": 0 } ] }

For more example, see the hostgroup.html

DELETE /api/v1/hostgroup/#{hostgroup_id} Delete HostGroup

  • Session Required ex. /api/v1/hostgroup/343
  • 如果使用者不是 Admin 只能对创建的hostgroup做操作

Response

Status: 200 {"message":"hostgroup:343 has been deleted"}

For more example, see the hostgroup.html

POST /api/v1/hostgroup Create HostGroup

Request

{"name":"testhostgroup"}

Response

Status: 200 { "id": 343, "grp_name": "testhostgroup", "create_user": "root" }

For more example, see the hostgroup.html

POST /api/v1/hostgroup/host Add Hosts to HostGroup

  • Session Required
  • Hosts 每次会覆盖该HostGroup内现有的Host List
  • 如果使用者不是 Admin 只能对创建的hostgroup做操作

Request

{ "hosts": [ "testhostgroup", "agent_test" ], "hostgroup_id": 343 }

Response

Status: 200 {"message":"[9312 9313] bind to hostgroup: 343"}

For more example, see the hostgroup.html

POST /api/v1/host/set_maintain_time Set maintain time for hosts

  • Session Required
  • hosts
    • []string
    • list of hosts
  • start_time
    • int
    • unix time
    • start_time & endt_time to 0 mean unset maintain time
  • end_time
    • int
    • unix time
    • start_time & endt_time to 0 mean unset maintain time

Request

{"start_time":1495447254,"hosts":["hostA","hostB"],"end_time":1495533650}

Response

Status: 200 [ { "id": 8, "hostname": "hostB", "ip": "0.0.0.1", "agent_version": "5.2.0", "plugin_version": "e1571b9944626b1aa7ab3075262e9b171854b4c7", "maintain_begin": 1495447254, "maintain_end": 1495533650 }, { "id": 1, "hostname": "hostA", "ip": "0.0.0.2", "agent_version": "5.1.4", "plugin_version": "12155256cec3926186de22e282e67f4ce11cdbf7", "maintain_begin": 1495447254, "maintain_end": 1495533650 } ]

For more example, see the host.html

GET /api/v1/host/#{host_id}/template Get bind Template List of Host

  • Session Required
  • ex. /api/v1/host/1647/template
  • tpl_name: template name

Response

Status: 200 [ { "id": 125, "tpl_name": "tplA", "parent_id": 0, "action_id": 99, "create_user": "root" }, { "id": 142, "tpl_name": "tplB", "parent_id": 0, "action_id": 111, "create_user": "root" }, { "id": 180, "tpl_name": "tplC", "parent_id": 0, "action_id": 142, "create_user": "root" } ]

For more example, see the host.html

GET /api/v1/host/#{host_id}/hostgroup Get related HostGorup of Host

  • Session Required
  • ex. /api/v1/host/1647/hostgroup
  • grp_name: hostgroup name

Response

Status: 200 [ { "id": 78, "grp_name": "tplB", "create_user": "userA" }, { "id": 145, "grp_name": "Owl_Default_Group", "create_user": "userA" } ]

For more example, see the host.html

POST /api/v1/graph/history Graph History

  • Session Required
  • dashobard 画图资料
  • consol_fun:
    • AVERAGE
    • MAX
    • MIN

Request

{ "step": 60, "start_time": 1481854596, "hostnames": [ "docker-a", "docker-b", "docker-c" ], "end_time": 1481858193, "counters": [ "cpu.idle", "cpu.iowait" ], "consol_fun": "AVERAGE" }

Response

Status: 200 [ { "endpoint": "docker-a", "counter": "cpu.idle", "dstype": "GAUGE", "step": 60, "Values": [ { "timestamp": 1481854620, "value": 98.154506 }, { "timestamp": 1481854680, "value": 97.864161 }, { "timestamp": 1481854740, "value": 97.521368 }, { "timestamp": 1481854800, "value": 97.587247 }, { "timestamp": 1481854860, "value": 97.440273 }, { "timestamp": 1481854920, "value": 97.914006 }, { "timestamp": 1481854980, "value": 97.223409 }, { "timestamp": 1481855040, "value": 98.029135 }, { "timestamp": 1481855100, "value": 97.614991 }, { "timestamp": 1481855160, "value": 97.565143 }, { "timestamp": 1481855220, "value": 97.070064 }, { "timestamp": 1481855280, "value": 98.726115 }, { "timestamp": 1481855340, "value": 98.720137 }, { "timestamp": 1481855400, "value": 98.205128 }, { "timestamp": 1481855460, "value": 97.70017 }, { "timestamp": 1481855520, "value": 97.780623 }, { "timestamp": 1481855580, "value": 97.379725 }, { "timestamp": 1481855640, "value": 98.034188 }, { "timestamp": 1481855700, "value": 98.246364 }, { "timestamp": 1481855760, "value": 98.372591 }, { "timestamp": 1481855820, "value": 98.152921 }, { "timestamp": 1481855880, "value": 97.914006 }, { "timestamp": 1481855940, "value": 95.592048 }, { "timestamp": 1481856000, "value": 94.11512 }, { "timestamp": 1481856060, "value": 97.596567 }, { "timestamp": 1481856120, "value": 97.501077 }, { "timestamp": 1481856180, "value": 96.374622 }, { "timestamp": 1481856240, "value": 89.570815 }, { "timestamp": 1481856300, "value": 96.410035 }, { "timestamp": 1481856360, "value": 97.567222 }, { "timestamp": 1481856420, "value": 97.25204 }, { "timestamp": 1481856480, "value": 95.356836 }, { "timestamp": 1481856540, "value": 97.330508 }, { "timestamp": 1481856600, "value": 96.999571 }, { "timestamp": 1481856660, "value": 97.278912 }, { "timestamp": 1481856720, "value": 97.229327 }, { "timestamp": 1481856780, "value": 97.212693 }, { "timestamp": 1481856840, "value": 96.503198 }, { "timestamp": 1481856900, "value": 96.790757 }, { "timestamp": 1481856960, "value": 98.121264 }, { "timestamp": 1481857020, "value": 98.550725 }, { "timestamp": 1481857080, "value": 97.548387 }, { "timestamp": 1481857140, "value": 98.466127 }, { "timestamp": 1481857200, "value": 97.9006 }, { "timestamp": 1481857260, "value": 97.985426 }, { "timestamp": 1481857320, "value": 97.357204 }, { "timestamp": 1481857380, "value": 97.086547 }, { "timestamp": 1481857440, "value": 98.770144 }, { "timestamp": 1481857500, "value": 97.727273 }, { "timestamp": 1481857560, "value": 98.595147 }, { "timestamp": 1481857620, "value": 97.867804 }, { "timestamp": 1481857680, "value": 98.128456 }, { "timestamp": 1481857740, "value": 97.886729 }, { "timestamp": 1481857800, "value": 95.969453 }, { "timestamp": 1481857860, "value": 97.134303 }, { "timestamp": 1481857920, "value": 98.033348 }, { "timestamp": 1481857980, "value": 96.511628 }, { "timestamp": 1481858040, "value": 96.522112 }, { "timestamp": 1481858100, "value": 97.49043 }, { "timestamp": 1481858160, "value": 96.958012 } ] }, { "endpoint": "docker-a", "counter": "cpu.iowait", "dstype": "GAUGE", "step": 60, "Values": [ { "timestamp": 1481854620, "value": 0.815451 }, { "timestamp": 1481854680, "value": 0.598035 }, { "timestamp": 1481854740, "value": 1.239316 }, { "timestamp": 1481854800, "value": 0.775528 }, { "timestamp": 1481854860, "value": 0.895904 }, { "timestamp": 1481854920, "value": 0.893997 }, { "timestamp": 1481854980, "value": 0.811619 }, { "timestamp": 1481855040, "value": 0.728363 }, { "timestamp": 1481855100, "value": 0.425894 }, { "timestamp": 1481855160, "value": 0.768902 }, { "timestamp": 1481855220, "value": 1.443737 }, { "timestamp": 1481855280, "value": 0.29724 }, { "timestamp": 1481855340, "value": 0.213311 }, { "timestamp": 1481855400, "value": 0.512821 }, { "timestamp": 1481855460, "value": 1.022147 }, { "timestamp": 1481855520, "value": 0.810926 }, { "timestamp": 1481855580, "value": 0.515464 }, { "timestamp": 1481855640, "value": 0.555556 }, { "timestamp": 1481855700, "value": 0.470488 }, { "timestamp": 1481855760, "value": 0.428266 }, { "timestamp": 1481855820, "value": 0.386598 }, { "timestamp": 1481855880, "value": 0.63857 }, { "timestamp": 1481855940, "value": 0.432152 }, { "timestamp": 1481856000, "value": 0.730241 }, { "timestamp": 1481856060, "value": 0.643777 }, { "timestamp": 1481856120, "value": 0.603188 }, { "timestamp": 1481856180, "value": 1.035822 }, { "timestamp": 1481856240, "value": 8.927039 }, { "timestamp": 1481856300, "value": 0.605536 }, { "timestamp": 1481856360, "value": 0.341443 }, { "timestamp": 1481856420, "value": 0.343495 }, { "timestamp": 1481856480, "value": 0.601892 }, { "timestamp": 1481856540, "value": 0.466102 }, { "timestamp": 1481856600, "value": 0.557222 }, { "timestamp": 1481856660, "value": 0.382653 }, { "timestamp": 1481856720, "value": 0.554135 }, { "timestamp": 1481856780, "value": 0.428816 }, { "timestamp": 1481856840, "value": 1.151386 }, { "timestamp": 1481856900, "value": 0.556269 }, { "timestamp": 1481856960, "value": 0.469684 }, { "timestamp": 1481857020, "value": 0.29838 }, { "timestamp": 1481857080, "value": 0.903226 }, { "timestamp": 1481857140, "value": 0.426076 }, { "timestamp": 1481857200, "value": 0.771208 }, { "timestamp": 1481857260, "value": 1.071582 }, { "timestamp": 1481857320, "value": 1.278772 }, { "timestamp": 1481857380, "value": 0.642674 }, { "timestamp": 1481857440, "value": 0.212044 }, { "timestamp": 1481857500, "value": 0.686106 }, { "timestamp": 1481857560, "value": 0.425713 }, { "timestamp": 1481857620, "value": 0.810235 }, { "timestamp": 1481857680, "value": 0.765632 }, { "timestamp": 1481857740, "value": 0.380389 }, { "timestamp": 1481857800, "value": 0.296988 }, { "timestamp": 1481857860, "value": 0.855432 }, { "timestamp": 1481857920, "value": 0.470286 }, { "timestamp": 1481857980, "value": 1.248923 }, { "timestamp": 1481858040, "value": 1.631602 }, { "timestamp": 1481858100, "value": 1.531263 }, { "timestamp": 1481858160, "value": 0.599829 } ] }, { "endpoint": "docker-b", "counter": "cpu.idle", "dstype": "GAUGE", "step": 60, "Values": [ { "timestamp": 1481854620, "value": 93.811775 }, { "timestamp": 1481854680, "value": 94.150538 }, { "timestamp": 1481854740, "value": 94.991438 }, { "timestamp": 1481854800, "value": 93.287435 }, { "timestamp": 1481854860, "value": 96.642584 }, { "timestamp": 1481854920, "value": 98.207426 }, { "timestamp": 1481854980, "value": 94.801875 }, { "timestamp": 1481855040, "value": 97.827939 }, { "timestamp": 1481855100, "value": 94.439692 }, { "timestamp": 1481855160, "value": 98.292787 }, { "timestamp": 1481855220, "value": 95.027624 }, { "timestamp": 1481855280, "value": 98.218074 }, { "timestamp": 1481855340, "value": 97.402044 }, { "timestamp": 1481855400, "value": 94.368601 }, { "timestamp": 1481855460, "value": 94.772631 }, { "timestamp": 1481855520, "value": 93.992331 }, { "timestamp": 1481855580, "value": 94.939446 }, { "timestamp": 1481855640, "value": 97.780623 }, { "timestamp": 1481855700, "value": 97.860505 }, { "timestamp": 1481855760, "value": 92.765411 }, { "timestamp": 1481855820, "value": 98.029979 }, { "timestamp": 1481855880, "value": 94.523502 }, { "timestamp": 1481855940, "value": 94.102564 }, { "timestamp": 1481856000, "value": 94.96587 }, { "timestamp": 1481856060, "value": 94.382979 }, { "timestamp": 1481856120, "value": 93.336181 }, { "timestamp": 1481856180, "value": 97.988875 }, { "timestamp": 1481856240, "value": 94.401709 }, { "timestamp": 1481856300, "value": 94.619983 }, { "timestamp": 1481856360, "value": 94.916702 }, { "timestamp": 1481856420, "value": 94.089733 }, { "timestamp": 1481856480, "value": 94.475375 }, { "timestamp": 1481856540, "value": 93.576017 }, { "timestamp": 1481856600, "value": 94.010195 }, { "timestamp": 1481856660, "value": 94.137783 }, { "timestamp": 1481856720, "value": 95.264505 }, { "timestamp": 1481856780, "value": 96.879008 }, { "timestamp": 1481856840, "value": 96.38759 }, { "timestamp": 1481856900, "value": 93.830334 }, { "timestamp": 1481856960, "value": 96.282051 }, { "timestamp": 1481857020, "value": 94.173093 }, { "timestamp": 1481857080, "value": 95.382642 }, { "timestamp": 1481857140, "value": 94.107452 }, { "timestamp": 1481857200, "value": 93.611584 }, { "timestamp": 1481857260, "value": 97.0538 }, { "timestamp": 1481857320, "value": 94.404101 }, { "timestamp": 1481857380, "value": 94.449189 }, { "timestamp": 1481857440, "value": 98.286938 }, { "timestamp": 1481857500, "value": 93.720632 }, { "timestamp": 1481857560, "value": 93.669803 }, { "timestamp": 1481857620, "value": 93.865294 }, { "timestamp": 1481857680, "value": 94.498934 }, { "timestamp": 1481857740, "value": 94.610778 }, { "timestamp": 1481857800, "value": 93.929029 }, { "timestamp": 1481857860, "value": 97.827939 }, { "timestamp": 1481857920, "value": 97.76824 }, { "timestamp": 1481857980, "value": 91.079014 }, { "timestamp": 1481858040, "value": 97.854998 }, { "timestamp": 1481858100, "value": 93.399482 }, { "timestamp": 1481858160, "value": 94.014536 } ] }, { "endpoint": "docker-b", "counter": "cpu.iowait", "dstype": "GAUGE", "step": 60, "Values": [ { "timestamp": 1481854620, "value": 0.171895 }, { "timestamp": 1481854680, "value": 0.645161 }, { "timestamp": 1481854740, "value": 0.47089 }, { "timestamp": 1481854800, "value": 0.731497 }, { "timestamp": 1481854860, "value": 0.594985 }, { "timestamp": 1481854920, "value": 0.256082 }, { "timestamp": 1481854980, "value": 0.340861 }, { "timestamp": 1481855040, "value": 0.255537 }, { "timestamp": 1481855100, "value": 0.684346 }, { "timestamp": 1481855160, "value": 0.384123 }, { "timestamp": 1481855220, "value": 0.084998 }, { "timestamp": 1481855280, "value": 0.466695 }, { "timestamp": 1481855340, "value": 1.192504 }, { "timestamp": 1481855400, "value": 0.511945 }, { "timestamp": 1481855460, "value": 0.594985 }, { "timestamp": 1481855520, "value": 0.383468 }, { "timestamp": 1481855580, "value": 1.038062 }, { "timestamp": 1481855640, "value": 0.981647 }, { "timestamp": 1481855700, "value": 0.599059 }, { "timestamp": 1481855760, "value": 0.770548 }, { "timestamp": 1481855820, "value": 0.428266 }, { "timestamp": 1481855880, "value": 0.301854 }, { "timestamp": 1481855940, "value": 0.598291 }, { "timestamp": 1481856000, "value": 0.853242 }, { "timestamp": 1481856060, "value": 0.723404 }, { "timestamp": 1481856120, "value": 1.025203 }, { "timestamp": 1481856180, "value": 0.470689 }, { "timestamp": 1481856240, "value": 0.213675 }, { "timestamp": 1481856300, "value": 0.768574 }, { "timestamp": 1481856360, "value": 0.256301 }, { "timestamp": 1481856420, "value": 0.388266 }, { "timestamp": 1481856480, "value": 0.342612 }, { "timestamp": 1481856540, "value": 0.813704 }, { "timestamp": 1481856600, "value": 0.594732 }, { "timestamp": 1481856660, "value": 0.684638 }, { "timestamp": 1481856720, "value": 1.535836 }, { "timestamp": 1481856780, "value": 0.25652 }, { "timestamp": 1481856840, "value": 0.38249 }, { "timestamp": 1481856900, "value": 1.028278 }, { "timestamp": 1481856960, "value": 1.025641 }, { "timestamp": 1481857020, "value": 0.642674 }, { "timestamp": 1481857080, "value": 0.726806 }, { "timestamp": 1481857140, "value": 0.649913 }, { "timestamp": 1481857200, "value": 0.809199 }, { "timestamp": 1481857260, "value": 0.256191 }, { "timestamp": 1481857320, "value": 0.512601 }, { "timestamp": 1481857380, "value": 0.59778 }, { "timestamp": 1481857440, "value": 0.342612 }, { "timestamp": 1481857500, "value": 1.19607 }, { "timestamp": 1481857560, "value": 0.983747 }, { "timestamp": 1481857620, "value": 0.900901 }, { "timestamp": 1481857680, "value": 0.639659 }, { "timestamp": 1481857740, "value": 0.641574 }, { "timestamp": 1481857800, "value": 0.598546 }, { "timestamp": 1481857860, "value": 0.425894 }, { "timestamp": 1481857920, "value": 0.729614 }, { "timestamp": 1481857980, "value": 0.339847 }, { "timestamp": 1481858040, "value": 0.686401 }, { "timestamp": 1481858100, "value": 0.560828 }, { "timestamp": 1481858160, "value": 0.51304 } ] }, { "endpoint": "docker-c", "counter": "cpu.idle", "dstype": "", "step": 0, "Values": [] }, { "endpoint": "docker-c", "counter": "cpu.iowait", "dstype": "", "step": 0, "Values": [] } ]

For more example, see the graph.html

GET /api/v1/graph/endpointsrt_counter Get Counter of Endpoint by endpoint names

  • Session Required
  • params:
    • endpoints: endpoint name lists
    • q: 使用 regex 查询字符
      • option 参数

Response

Status: 200 [ "df.inodes.free.percent/fstype=ext4,mount=/", "disk.io.read_sectors/device=sda", "disk.io.write_merged/device=sdh", "net.if.total.packets/iface=eth4", "snmp.Udp.RcvbufErrors" ]

For more example, see the graph.html

GET /api/v1/graph/endpoint Endpoint List

  • Session Required
  • q: 使用 regex 查询字符
    • option 参数

Response

Status: 200 [ { "endpoint": "docker-agent", "id": 7 }, { "endpoint": "docker-task", "id": 6 }, { "endpoint": "graph", "id": 3 }, { "endpoint": "nodata", "id": 920 }, { "endpoint": "task", "id": 5 } ]

For more example, see the graph.html

GET /api/v1/graph/endpoint_counter Get Counter of Endpoint

  • Session Required
  • params:
    • eid: endpoint id list
    • q: 使用 regex 查询字符
      • option 参数

Response

Status: 200 [ "disk.io.avgqu-sz/device=sda", "disk.io.ios_in_progress/device=sda", "disk.io.msec_read/device=sda", "disk.io.read_requests/device=sda", ... ]

For more example, see the graph.html

PUT /api/v1/expression Update Expression

Request

{ "right_value": "0", "priority": 2, "pause": 1, "op": "==", "note": "this is a test exp", "max_step": 3, "id": 5, "func": "all(#3)", "expression": "each(metric=agent.alive endpoint=docker-agent)", "action": { "url": "http://localhost:1234/callback", "uic": [ "test", "test2" ], "callback": 0, "before_callback_sms": 1, "before_callback_mail": 0, "after_callback_sms": 1, "after_callback_mail": 0 } }

Response

Status: 200 {"message":"expression:5 has been updated"}

For more example, see the expression.html

GET /api/v1/expression Expression List

Response

Status: 200 [ { "id": 2, "expression": "each(metric=? xx=yy)", "func": "all(#3)", "op": "==", "right_value": "0", "max_step": 3, "priority": 0, "note": "", "action_id": 18, "create_user": "root", "pause": 0 }, { "id": 3, "expression": "each(metric=ss.close.wait endpoint=docker-A)", "func": "all(#1)", "op": "!=", "right_value": "0", "max_step": 1, "priority": 4, "note": "boss docker-A 连接数大于10", "action_id": 91, "create_user": "root", "pause": 0 }, { "id": 4, "expression": "each(metric=agent.alive endpoint=docker-agent)", "func": "all(#3)", "op": "==", "right_value": "0", "max_step": 3, "priority": 2, "note": "this is a test exp", "action_id": 176, "create_user": "root", "pause": 1 } ]

For more example, see the expression.html

GET /api/v1/expression/#{expression_id} Get Expression Info by id

  • Session Required ex. /api/v1/expression/5

Response

Status: 200 { "action": { "id": 5, "uic": "taipei", "url": "", "callback": 0, "before_callback_sms": 0, "before_callback_mail": 0, "after_callback_sms": 0, "after_callback_mail": 0 }, "expression": { "id": 5, "expression": "each(metric=agent.alive endpoint=docker-agent)", "func": "all(#3)", "op": "==", "right_value": "0", "max_step": 3, "priority": 2, "note": "this is a test exp", "action_id": 177, "create_user": "root", "pause": 1 } }

For more example, see the expression.html

DELETE /api/v1/expression/#{expression_id} Delete Expression

  • Session Required
  • ex. /api/v1/expression/5

Response

Status: 200 {"message":"expression:5 has been deleted"}

For more example, see the expression.html

POST /api/v1/expression Create Expression

Request

{ "right_value": "0", "priority": 2, "pause": 0, "op": "==", "note": "this is a test exp", "max_step": 3, "func": "all(#3)", "expression": "each(metric=agent.alive endpoint=docker-agent)", "action": { "url": "http://localhost:1234/callback", "uic": [ "test" ], "callback": 1, "before_callback_sms": 1, "before_callback_mail": 0, "after_callback_sms": 1, "after_callback_mail": 0 } }

Response

Status: 200 {"message":"expression created"}

For more example, see the expression.html

GET /api/v1/aggregators Get Aggreator Info by id

Request

{ "tags": "", "step": 60, "numerator": "$(cpu.idle)", "metric": "test.idle", "hostgroup_id": 343, "endpoint": "testenp", "denominator": "2" }

Response

Status: 200 { "id": 16, "grp_id": 343, "numerator": "$(cpu.idle)", "denominator": "2", "endpoint": "testenp", "metric": "test.idle", "tags": "", "ds_type": "GAUGE", "step": 60, "creator": "root" }

For more example, see the aggreator.html

PUT /api/v1/aggregators Update Aggreator

  • Session Required
  • numerator: 分子
  • denominator: 分母
  • step: 汇报周期(秒为单位)

Request

{ "tags": "", "step": 60, "numerator": "$(cpu.idle)", "metric": "test.idle", "id": 16, "endpoint": "testenp", "denominator": "$#" }

Response

Status: 200 { "id": 16, "grp_id": 343, "numerator": "$(cpu.idle)", "denominator": "$#", "endpoint": "testenp", "metric": "test.idle", "tags": "", "ds_type": "GAUGE", "step": 60, "creator": "root" }

For more example, see the aggreator.html

GET /api/v1/hostgroup/#{hostgroup_id}/aggregators Get Aggreator List of HostGroup

  • Session Required
  • ex. /api/v1/hostgroup/343/aggregators
  • numerator: 分子
  • denominator: 分母
  • step: 汇报周期(秒为单位)

Response

Status: 200 [ { "id": 13, "grp_id": 343, "numerator": "$(cpu.idle)", "denominator": "2", "endpoint": "testenp", "metric": "test.idle", "tags": "", "ds_type": "GAUGE", "step": 60, "creator": "root" }, { "id": 14, "grp_id": 343, "numerator": "$(cpu.idle)", "denominator": "2", "endpoint": "testenp", "metric": "test.idle", "tags": "", "ds_type": "GAUGE", "step": 60, "creator": "root" } ]

For more example, see the aggreator.html

DELETE /api/v1/aggregator/16 Delete Aggreator

Response

Status: 200 {"message":"aggregator:16 is deleted"}

For more example, see the aggreator.html

GET /api/v1/aggregators Create Aggreator to a HostGroup

  • Session Required
  • numerator: 分子
  • denominator: 分母
  • step: 汇报周期(秒为单位)

Request

{ "tags": "", "step": 60, "numerator": "$(cpu.idle)", "metric": "test.idle", "hostgroup_id": 343, "endpoint": "testenp", "denominator": "2" }

Response

Status: 200 { "id": 16, "grp_id": 343, "numerator": "$(cpu.idle)", "denominator": "2", "endpoint": "testenp", "metric": "test.idle", "tags": "", "ds_type": "GAUGE", "step": 60, "creator": "root" }

For more example, see the aggreator.html

DELETE /api/v1/admin/delete_user Delete User

Request

{"user_id": 31}

Response

Status: 200 {"message":"user 31 has been delete, affect row: 1"}

For more example, see the admin.html

PUT /api/v1/admin/change_user_passwd Change User's Password

Request

{"user_id": 14, "password": "newpasswd"}

Response

Status: 200 {"message":"password updated!"}

For more example, see the admin.html

PUT /api/v1/admin/change_user_role Change User's role

  • Session Required
  • Admin usage
  • admin:
    • accept option:
      • yes
      • no

Request

{"user_id": 14, "admin": "yes"}

Response

Status: 200 {"message":"user role update sccuessful, affect row: 1"}

For more example, see the admin.html

Response status codes

Success

  • POST, GET, PUT, DELETE returns 200 on success,
  • 当参数使用不正确的时候会回覆 400

参考

return code 请参考 status.go

GET /api/v1/user/login Auth Session

透过Session检查去判定使用者可否存取资源

RequestHeader

透过RequestHeader 的 Apitoken做验证 "RequestHeader": { "Apitoken": "{\"name\":\"root\",\"sig\":\"427d6803b78311e68afd0242ac130006\"}", "X-Forwarded-For": " 127.0.0.1" }

Response

Session 为有效 Status: 200 {"message":"session is vaild!"}

For errors responses, see the response status codes documentation.