Pylint no-else-return refactoring: tenth (and so far last) set of files
[check_mk.git] / .werks / 6240
blob6f5dd95c4c3596f39c9043b90b77cf6c68a29ccd
1 Title: WATO Web-API: Implemented SLA API interface
2 Level: 1
3 Component: wato
4 Class: feature
5 Compatible: compat
6 Edition: cee
7 State: unknown
8 Version: 1.6.0i1
9 Date: 1530272014
12 SLA data for services can now be fetched via the Web API.
13 The new action is named <tt>get_sla</tt>.
15 The request object is structured like this:
17 F+:
19     "query": [ [[{sla_configuration}], [{timerange_spec_1}], [{host/service pair}]] ]
21 F-:
23 A query entry always consists of 3 fields.
24 <ul>
25 <li>The list of sla_definitions</li>
26 <li>The list of timerange specificiations</li>
27 <li>The list of host/service pairs</li>
28 </ul>
30 The sla_definition is simply the id of the configured SLA definition.
32 The timerange specification has some special syntax
33 Some examples:
34 F+:
35 #                                 # Field to send in query
36 #            "Today"              # "d0"
37 #            "Yesterday"          # "d1"
39 #            "This week"          # "w0"
40 #            "Last week"          # "w1"
42 #            "This month"         # "m0"
43 #            "Last month"         # "m1"
45 #            "This year"          # "y0"
46 #            "Last year"          # "y1"
48 #            "The last..."        # "last:86400"
49 #            "Time range"         # "range:1530271236:1530281236"
51 # SLA configurations have no distinct timestamp. The timestamp depends on the SLA period
52 # The following example says
53 # - Start at the penultimate sla period (Note: 0 is current period)
54 # - Look back additional 4 sla periods
55 # There will be 5 period results
56 #            "Sla period range"   # "sla:2:4"
57 F-:
59 The of host/service pairs identifies the required services.
61 A valid request may look like
62 F+:
64     "query": [ [["sla_configuration_1"], ["w1"], [["HostA", "ServiceB"]]] ]
66 F-:
67 This queries the sla_configuration_1 with the timerange "Last week" for the service HostA/ServiceB.
68 This returns 1 result.
71 As you might have noticed, each field in the query is enclosed by a list.
72 That's because each query entry may have multiple values specified.
73 F+:
75     "query": [ [["sla_configuration_1", "sla_configuration_2"], ["w1"], [["HostA", "ServiceB"]]] ]
77 F-:
78 This queries the sla_configuration_1 and sla_configuration_2 with the timerange "Last week" for the service HostA/ServiceB.
79 This returns 2 results.
82 Now add an additional timerange specification
83 F+:
85     "query": [ [["sla_configuration_1", "sla_configuration_2"], ["w1", "w0"], [["HostA", "ServiceB"]]] ]
87 F-:
88 This queries the sla_configuration_1 and sla_configuration_2 with the timerange "Last week" and "This week" for the service HostA/ServiceB.
89 This returns 4 results.
93 Finally, you can also add additional triples to the query.
94 F+:
96     "query": [ [["sla_configuration_1"], ["w1"], [["HostA", "ServiceB"]]],
97                [["sla_configuration_2"], ["w0"], [["HostX", "ServiceY"]]] ]
99 F-:
100 This queries sla_configuration_1 with the timerange "Last week" for HostA/ServiceB and
101 sla_configuration_2 with the timerange "This week" for HostX/ServiceY.
105 The returned result for these queries is a python dictionary with lots of infos
107 {'mysite': {'myhost': {'CPU load':
108     {(('myhost', 'CPU load'), 'sla_configuration_1', ('sla_period_range', (0, 1)), 'weekly'):
109             {'plugin_results': [{'period_results': [{'duration': 604800.0,
110                                                      'sla_broken': False,
111                                                      'statistics': {'duration': {-1: 604800.0},
112                                                                     'percentage': {-1: 100.0}},
113                                                      'subresults': [{'deviation_info': {'deviation': 0.0,
114                                                                                         'deviation_state': 2,
115                                                                                         'levels': (0,
116                                                                                                    0),
117                                                                                         'limit': 0.0},
118                                                                      'error_instances': [],
119                                                                      'requirement': (0,
120                                                                                      'min',
121                                                                                      0.0),
122                                                                      'sla_broken': False}],
123                                                      'timerange': (1529272800.0,
124                                                                    1529877600.0)},
125                                                     {'duration': 396134.0,
126                                                      'sla_broken': False,
127                                                      'statistics': {'duration': {-1: 385358.0,
128                                                                                  0: 10776},
129                                                                     'percentage': {-1: 97.27970838150726,
130                                                                                    0: 2.7202916184927326}},
131                                                      'subresults': [{'deviation_info': {'deviation': 2.7202916184927326,
132                                                                                         'deviation_state': 0,
133                                                                                         'levels': (0,
134                                                                                                    0),
135                                                                                         'limit': 0.0},
136                                                                      'error_instances': [],
137                                                                      'requirement': (0,
138                                                                                      'min',
139                                                                                      0.0),
140                                                                      'sla_broken': False}],
141                                                      'timerange': (1529877600.0,
142                                                                    1530273734)}],
143                                  'plugin_id': 'service_state_percentage',
144                                  'timerange_sla_duration': 1000934.0}],
145              'sla_id': 'sla_configuration_1',
146              'sla_period': 'weekly'}}}}}
148 Keep in mind that this API implementation is an initial version, so there might be interface changes within the next months.