PUT /api/v1/user/u/:uid Update Specific User

更新使用者

Request

{ "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

POST /api/v1/team/user Add users to team

添加用户到某个组

  • Session Required
  • users: 待添加到 team 中的用户名列表
  • team_id: 目标 team 的 team_id

Request

{ "team_id": 107, "users": ["root", "test1"] }

Response

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

For more example, see the

POST /api/v1/admin/login Admin Login

SSO 登入

Request

{ "name": "test2", }

Response

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

For errors responses, see the response status codes documentation.

For more example, see the admin.html

PATCH /api/v1/hostgroup/#{hostgroup_id}/host Update partial hosts in HostGroup

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

Request

{ "hosts": [ "host01", "host02" ], "action": "add" }

Response

Status: 200 { "message": "[host01, host02] bind to hostgroup: test, [] have been exist" }

Request

{ "hosts": [ "host01", "host02" ], "action": "remove" }

Response

Status: 200 { "message": "[host01, host02] unbind to hostgroup: test" }

For more example, see the hostgroup.html

PUT /api/v1/user/update Update User

更新使用者

Request

{ "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/:uid/in_teams Check user in teams or not

  • Session Required
  • ex. /api/v1/user/u/4/in_teams?team_names=team1,team4

Request

Content-type: application/x-www-form-urlencoded team_names=team1,team2

Response

Status: 200 {"message":"true"}

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/:uid/teams Get user teams

  • Session Required
  • ex. /api/v1/user/u/4/teams

Response

Status: 200 {"teams": [{ "id":3, "name":"root", "resume":"", "creator":5}, {"id":32, "name":"testteam", "resume":"test22", "creator":5 }] }

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/name/#{user_name} Get User info by name

  • Session Required
  • Admin usage
  • ex. /api/v1/user/name/laiwei

Response

Status: 200 { "cnname": "laiwei8", "email": "laiwei8@xx", "id": 8, "im": "", "name": "laiwei8", "phone": "", "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/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

GET /api/v1/template/#{template_id}/hostgroup Get hostgroups list by id

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

Response

Status: 200 { "hostgroups": [{ "id":33, "grp_name":"HostGroup", "create_user":"root" } ], "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 { "id": 2, "parent_id": 0, "tpl_name": "AtmpForTesting", "action_id": 0, "create_user": "root" }

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的描述
  • name: team的名字
  • 除Admin外, 使用者只能更新自己创建的team

Request

{ "team_id": 107, "name": "new_name", "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/name/#{team_name} Get Team Info by name

  • Session Required
  • ex. /api/v1/team/name/plus-dev

Response

Status: 200 { "creator": 6, "creator_name": "", "id": 10, "name": "plus-dev", "resume": "test intro", "users": [ { "cnname": "laiwei", "email": "laiwei@xxx.com", "id": 1, "im": "yyyyx", "name": "laiwei1", "phone": "15011518472", "qq": "3805112124444455", "role": 2 } ] }

For more example, see the team.html

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

  • Session Required
  • ex. /api/v1/team/t/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```

{ “id”: 2, “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)” } ```

For more example, see the template.html

GET /api/v1/metric/default_list Get Default Builtin 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/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/update/#{hostgroup_id} Update HostGroup info by id

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

Request

{ "id" : 343, "grp_name": "test1" }

Response

Status: 200 { "message":"hostgroup profile updated" }

For more example, see the hostgroup.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

DELETE /api/v1/host/maintain Reset host maintain by ids or hostnames

Request

{"ids": [1,2,3,4]} or {"hosts": ["host.a","host.b"]}

Response

Status: 200 { "message": "Through: hosts, Affect row: 2" }

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/host/maintain Set host maintain by ids or hostnames

Request

{
    "ids": [1,2,3,4],
    "maintain_begin": 1497951907,
    "maintain_end": 1497951907
}

or

{
    "hosts": ["host.a","host.b"],
    "maintain_begin": 1497951907,
    "maintain_end": 1497951907
}

Response

Status: 200 { "message": "Through: hosts, Affect row: 2" }

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

POST /v1/grafana/render Grafan query

  • target: grafana query查询串 (type: []string)
    • 支援多组查询条件.
    • ex. [“{host-A}#cpu#idel”, “{1.1.1.1,2.2.2.2,3.3.3.3}#cpu#idle”]
    • 為了支援ip & 一些实做的限制. 所以将 “.” 制换成 “#”
    • {}# 后面代入的的counter 会作為查询counter的依据. 可以支援regex match. 例如 #.+cpu.+ 会将所有包含cpu字眼的counter一并查询返回数据画图
    • 有时想要找特定的counter可以善用regex语法 “^” or “$” 去限定字串的范围 ex. [“{host-A}#^cpu#idel$”]
    • 这边保留很大的弹性, 有特殊需求的可以自行修改判断逻辑
  • from: start time (unix time)
  • until: end time (unix time)
  • step: 查询graph时, 指定step interval
    • default: 60
  • ConsolFun: 取样 -> [“AVERAGE”, “MAX”, “MIN”]
    • default: “AVERAGE”

Response

Status: 200 [ { "endpoint": "host-A", "counter": "cpu.idle", "dstype": "GAUGE", "step": 60, "Values": [ { "timestamp": 1506698040, "value": 55.934343 }, { "timestamp": 1506698100, "value": 44.656489 } ] } ]

GET /api/v1/graph/endpoint Endpoint List

  • Session Required
  • params:
    • q: 使用 regex 查询字符
      • option 参数
    • page: 【选填】分页查询的页码,默认值:1,如: page=2 表示第2页
    • limit: 【选填】分页查询的页大小,默认值:500,如:limit=10 表示每页10条数据

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
    • metricQuery: 查询counter参数【选填】。如:metricQuery=device=sda
    • page: 【选填】分页查询的页码,默认值:1,如: page=2 表示第2页
    • limit: 【选填】分页查询的页大小,默认值:500,如:limit=10 表示每页10条数据
    • 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

PUT /api/v1/dashboard/screen/:screen_id Update a DashboardScreen

Request

Content-type: application/x-www-form-urlencoded

name=laiwei-sceen1&pid=0

Response

Status: 200 {"message":"ok"}

For errors responses, see the response status codes documentation.

For more example, see the dashboard.html

GET /api/v1/dashboard/screens/pid/:screen_pid Gets DashboardScreens by pid

Response

Status: 200

[
    {
        "id": 952,
        "name": "a1",
        "pid": 0
    },
    {
        "id": 961,
        "name": "laiwei-sceen1",
        "pid": 0
    }
]

For errors responses, see the response status codes documentation.

For more example, see the dashboard.html

GET /api/v1/dashboard/screens Gets all DashboardScreens

Request

Content-type: application/x-www-form-urlencoded

  • params:
    • limit: 【选填】查询最大数据量,默认值:500,如:limit=10 只查询最多10条数据

Response

Status: 200

[
    {
        "id": 952,
        "name": "a1",
        "pid": 0
    },
    {
        "id": 953,
        "name": "aa1",
        "pid": 952
    },
    {
        "id": 968,
        "name": "laiwei-screen2",
        "pid": 1
    },
    {
        "id": 972,
        "name": "laiwei-sceen1",
        "pid": 0
    },
    {
        "id": 991,
        "name": "xnew",
        "pid": 972
    },
    {
        "id": 993,
        "name": "clone3",
        "pid": 972
    },
    {
        "id": 995,
        "name": "op",
        "pid": 0
    }
]

For errors responses, see the response status codes documentation.

For more example, see the dashboard.html

GET /api/v1/dashboard/screen/:screen_id Get a DashboardScreen by id

Response

Status: 200 {"id":961,"pid":0,"name":"laiwei-sceen1"}

For errors responses, see the response status codes documentation.

For more example, see the dashboard.html

DELETE /api/v1/dashboard/screen/:screen_id Delete a DashboardScreen

Response

Status: 200 {"message":"ok"}

For errors responses, see the response status codes documentation.

For more example, see the dashboard.html

POST /api/v1/dashboard/screen Create a DashboardScreen

Request

Content-type: application/x-www-form-urlencoded

name=laiwei-sceen1&pid=0

Response

Status: 200 {"name":"laiwei-sceen1","pid":0,"screen_id":961}

For errors responses, see the response status codes documentation.

For more example, see the dashboard.html

GET /api/v1/dashboard/graphs/screen/:screen_id Gets graphs by screen id

Response

Status: 200

[
    {
        "counters": [
            "value/name=pfc.push.ms"
        ],
        "endpoints": [
            "laiweiofficemac"
        ],
        "falcon_tags": "",
        "graph_id": 4640,
        "graph_type": "h",
        "method": "",
        "position": 0,
        "screen_id": 991,
        "timespan": 3600,
        "title": "dddd"
    },
    {
        "counters": [
            "aaa"
        ],
        "endpoints": [
            "xxx"
        ],
        "falcon_tags": "",
        "graph_id": 4641,
        "graph_type": "h",
        "method": "SUM",
        "position": 0,
        "screen_id": 991,
        "timespan": 3600,
        "title": "dddd"
    }
]

For errors responses, see the response status codes documentation.

For more example, see the dashboard.html

PUT /api/v1/dashboard/graph/:id Update a DashboardGraph

Request

{
    "counters": ["value/name=pfc.push.ms","value/name=pfc.push.size", "agent.alive"],
    "falcon_tags": "srv=falcon"
}

Response

Status: 200

{"message":"ok"}

For errors responses, see the response status codes documentation.

For more example, see the dashboard.html

GET /api/v1/dashboard/tmpgraph/:id Get a tmpgraph by id

Response

Status: 200

{"counters":["agent.alive"],"endpoints":["laiweiofficemac"]}

For errors responses, see the response status codes documentation.

For more example, see the dashboard.html

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

Response

Status: 200 { "counters":["value/name=pfc.push.ms", "value/name=pfc.push.size"], "endpoints":["laiweiofficemac"], "falcon_tags":"", "graph_id":4626, "graph_type":"h", "method":"", "position":4626, "screen_id":953, "timespan":3600, "title":"test" }

For errors responses, see the response status codes documentation.

For more example, see the dashboard.html

DELETE /api/v1/dashboard/graph/:id Delete a DashboardGraph

Response

Status: 200

{"message":"ok"}

For errors responses, see the response status codes documentation.

For more example, see the dashboard.html

POST /api/v1/dashboard/tmpgraph Create a tmpgraph

Request

{"endpoints":["e1", "e2"], "counters":["c1", "c2"]}

Response

Status: 200

{
    "ck": "68c07419dbd7ac65977c97d05d99440d",
    "counters": "c1|c2",
    "endpoints": "e1|e2",
    "id": 365195
}

For errors responses, see the response status codes documentation.

For more example, see the dashboard.html

POST /api/v1/dashboard/graph Create User

Request

{
    "screen_id": 953,
    "title": "laiwei-test-graph1",
    "endpoints": ["laiweiofficemac"],
    "counters": ["value/name=pfc.push.ms","value/name=pfc.push.size"],
    "timespan": 1800, 
    "graph_type": "h", 
    "method": "AVG",
    "position": 0
}

Response

Status: 200

{"message":"ok"}

For errors responses, see the response status codes documentation.

For more example, see the dashboard.html

POST /api/v1/alarm/events Create Events

Request

Content-type: application/x-www-form-urlencoded

Key Value
endTime 1466628960
event_id s_165_cef145900bf4e2a4a0db8b85762b9cdb
startTime 1466611200

Response

Status: 200

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

For errors responses, see the response status codes documentation.

For more example, see the alarm.html

GET /api/v1/alarm/event_note Get Event Note by id or time range

Request

Content-type: application/x-www-form-urlencoded

or
```event_id=s_165_cef145900bf4e2a4a0db8b85762b9cdb```


### Response

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

For errors responses, see the response status codes documentation.

For more example, see the alarm.html

POST /api/v1/alarm/event_note Create Event Note

Request

    {
        "event_id": "s_165_cef145900bf4e2a4a0db8b85762b9cdb",
        "note": "test note",
        "status": "comment"
    }

Response

Status: 200

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

For errors responses, see the response status codes documentation.

For more example, see the alarm.html

POST /api/v1/alarm/eventcases EventCases List

Request

    {
        "endTime": 1480521600,
        "limit": 10,
        "process_status": "ignored,unresolved",
        "startTime": 1466956800,
        "status": "PROBLEM",
        "endpoints": ["agent4"],
        "strategy_id": 46,
        "template_id": 126
    }

Response

Status: 200

    {
        "closed_at": null,
        "closed_note": "",
        "cond": "48.33759590792839 > 40",
        "current_step": 1,
        "endpoint": "agent4",
        "expression_id": 0,
        "func": "all(#3)",
        "id": "s_46_1ac45122afb893adc02fbd30154ac303",
        "metric": "cpu.iowait",
        "note": "CPU I/O wait\u74d2\u5470\u7e4340",
        "priority": 1,
        "process_note": 16907,
        "process_status": "ignored",
        "status": "PROBLEM",
        "step": 1,
        "strategy_id": 46,
        "template_id": 126,
        "timestamp": "2016-08-01T06:25:00+08:00",
        "tpl_creator": "root",
        "update_at": "2016-08-01T06:25:00+08:00",
        "user_modified": 0
    }
]

For errors responses, see the response status codes documentation.

For more example, see the alarm.html

GET /api/v1/alarm/eventcases Get EventCases by id

Request

Content-type: application/x-www-form-urlencoded

event_id=s_165_cef145900bf4e2a4a0db8b85762b9cdb

Response

Status: 200

    [
        {
            "closed_at": null,
            "closed_note": "",
            "cond": "0 != 66",
            "current_step": 3,
            "endpoint": "agent2",
            "expression_id": 0,
            "func": "all(#1)",
            "id": "s_165_cef145900bf4e2a4a0db8b85762b9cdb",
            "metric": "cpu.idle",
            "note": "\u5a13\ue103\u2502\u935b\u5a45\ue11f\u9477\ue044\u5aca\u93c7\u5b58\u67ca",
            "priority": 0,
            "process_note": 56603,
            "process_status": "ignored",
            "status": "PROBLEM",
            "step": 300,
            "strategy_id": 165,
            "template_id": 45,
            "timestamp": "2017-03-23T15:51:11+08:00",
            "tpl_creator": "root",
            "update_at": "2016-06-23T05:00:00+08:00",
            "user_modified": 0
        }
    ]

For errors responses, see the response status codes documentation.

For more example, see the alarm.html

GET /api/v1/aggregators Get Aggregator 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 aggregator.html

PUT /api/v1/aggregators Update Aggregator

  • 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 aggregator.html

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

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

Response

Status: 200 { "hostgroup": "test_group", "aggregators": [ { "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 aggregator.html

DELETE /api/v1/aggregator/16 Delete Aggregator

Response

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

For more example, see the aggregator.html

POST /api/v1/aggregator Create Aggregator 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 aggregator.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/auth_session 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.