Licenses: Updated the list of licenses and added a PDF containing all license texts
[check_mk.git] / .werks / 8643
blobfbcde058f6e7d945ceee8f54feb4e3e6837671f4
1 Title: Web API: New API for fetching graph data
2 Level: 2
3 Edition: cee
4 Component: metrics
5 Compatible: compat
6 Version: 1.4.0i3
7 Date: 1480670396
8 Class: feature
10 The raw data of the Check_MK graphs can now be fetched via the Web API. The new
11 action is named <tt>get_graph</tt>.
13 The request object is structured like this:
15 F+:
17     "specification": [..., ...],
18     "data_range": {
19         "time_range" : [..., ...],
20     }
22 F-:
24 The specification is using the Check_MK internal graph specification
25 format. The first element is the specification type (<tt>template</tt>,
26 <tt>custom</tt> or <tt>explicit</tt>.  The structure of the second element
27 depends on the type. Please take a look at the examples below to get an idea
28 of it.
30 The time range is given in two unix timestamps, the start time and the
31 end time.
33 For example this command can be used to fetch the first graph of the Check_MK
34 service of the host myhost123:
36 C+:
37 UP:curl "http://mycmkserver/mysite/check_mk/webapi.py?action=get_graph&_username=automation&_secret=af665c15-5728-4541-b5bf-04d1d98deee8" -d 'request={"specification": ["template", {"service_description": "Check_MK", "site": "mysite", "graph_index": 0, "host_name": "myhost123" }], "data_range": {"time_range": [1480653120, 1480667520]}}'
38 C-:
40 The answer may look like this:
42 F+:
44     "result": {
45         "step": 60,
46         "start_time": 1480653120,
47         "end_time": 1480667520,
48         "curves": [
49             {
50                 "color": "#87f058",
51                 "rrddata": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 0.05, 0.059, 0.0423333, 0.0488333, 0.0413333, 0.0573333, 0.0515, 0.05, 0.05, 0.05, 0.05, 0.058, 0.052, 0.0578333, 0.0365, 0.0453333, 0.0576667, 0.0525, 0.05, 0.0573333, 0.0526667, 0.0428333, 0.0471667, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.0436667, 0.0526667, 0.06, 0.06, 0.054, 0.05, 0.0558333, 0.0541667, 0.0556667, 0.049, 0.0455, 0.0553333, 0.0493333, 0.04, 0.0451667, 0.05, 0.05, 0.05],
52                 "line_type": "stack",
53                 "title": "CPU time in user space"
54             },
55         ]
56     },
57     "result_code": 0
59 F-:
61 This command is used to fetch the data of a custom graph named <tt>custom_graph_1</tt>:
63 C+:
64 UP:curl "http://mycmkserver/mysite/check_mk/webapi.py?action=get_graph&_username=automation&_secret=af665c15-5728-4541-b5bf-04d1d98deee8" -d 'request={"specification": ["custom", "custom_graph_1"], "data_range": {"time_range": [1480653120, 1480667520]}}'
65 C-: