Checkmk / grafana-checkmk-datasource

CheckMK data source for Grafana
Apache License 2.0
83 stars 14 forks source link

Cannot obtain data from a service containing a plus sign #245

Closed airforceixi closed 6 months ago

airforceixi commented 6 months ago

Monitoring some Wireguard peers via CheckMK and Grafana is unable to display any peers containing a plus sign in the peer key. Appears to be an interpreting the + as a space. Below are the Grafana query and error.

{
  "request": {
    "url": "api/datasources/proxy/uid/f2e1c855-c920-4be0-826b-65f29496f2f4/cmk/check_mk/webapi.py?action=get_graph",
    "data": "request={\"specification\":[\"template\",{\"site\":\"[REDACTED]\",\"host_name\":\"[REDACTED]\",\"service_description\":\"WireGuard wg0 Peer nCnVnG/eLbqu0AS8ROTxehqQ+hO/aHNcCOyLQfN15is\",\"graph_name\":\"bandwidth_translated\"}],\"data_range\":{\"time_range\":[1709305413,1709327013]}}",
    "method": "POST",
    "hideFromInspector": false
  },
  "response": {
    "result_code": 1,
    "result": "Checkmk exception: Cannot calculate graph recipes: No matching entries found for query: GET services
Columns: perf_data metrics check_command
Filter: host_name = [REDACTED]
Filter: service_description = WireGuard wg0 Peer nCnVnG/eLbqu0AS8ROTxehqQ hO/aHNcCOyLQfN15is

Traceback (most recent call last):
  File \"/omd/sites/[REDACTED]/lib/python3/livestatus.py\", line 237, in query_row
    return result[0]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \"/omd/sites/[REDACTED]/lib/python3/cmk/gui/plugins/metrics/graph_images.py\", line 223, in graph_recipes_for_api_request
    graph_recipes = graph_identification_types.create_graph_recipes(graph_identification)
  File \"/omd/sites/[REDACTED]/lib/python3/cmk/gui/plugins/metrics/identification.py\", line 58, in create_graph_recipes
    return type_cls().create_graph_recipes(spec_info, destination=destination)
  File \"/omd/sites/[REDACTED]/lib/python3/cmk/gui/plugins/metrics/graph_templates.py\", line 94, in create_graph_recipes
    row = get_graph_data_from_livestatus(site, host_name, service_description)
  File \"/omd/sites/[REDACTED]/lib/python3/cmk/gui/plugins/metrics/utils.py\", line 967, in get_graph_data_from_livestatus
    info = dict(zip(labels, sites.live().query_row(query)))
  File \"/omd/sites/[REDACTED]/lib/python3/livestatus.py\", line 239, in query_row
    raise MKLivestatusNotFoundError(
livestatus.MKLivestatusNotFoundError: No matching entries found for query: GET services
Columns: perf_data metrics check_command
Filter: host_name = [REDACTED]
Filter: service_description = WireGuard wg0 Peer nCnVnG/eLbqu0AS8ROTxehqQ hO/aHNcCOyLQfN15is

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \"/omd/sites/[REDACTED]/lib/python3/cmk/gui/webapi.py\", line 116, in page_api
    resp = _execute_action(api_call, request_object)
  File \"/omd/sites/[REDACTED]/lib/python3/cmk/gui/webapi.py\", line 207, in _execute_action
    return _execute_action_no_lock(api_call, request_object)
  File \"/omd/sites/[REDACTED]/lib/python3/cmk/gui/webapi.py\", line 221, in _execute_action_no_lock
    \"result\": api_call[\"handler\"](request_object),
  File \"/omd/sites/[REDACTED]/lib/python3/cmk/gui/plugins/webapi/graphs.py\", line 35, in _get_graph
    return graph_spec_from_request(request)
  File \"/omd/sites/[REDACTED]/lib/python3/cmk/gui/plugins/metrics/graph_images.py\", line 235, in graph_spec_from_request
    graph_data_range, graph_recipes = graph_recipes_for_api_request(api_request)
  File \"/omd/sites/[REDACTED]/lib/python3/cmk/gui/plugins/metrics/graph_images.py\", line 225, in graph_recipes_for_api_request
    raise MKUserError(None, _(\"Cannot calculate graph recipes: %s\") % e)
cmk.gui.exceptions.MKUserError: Cannot calculate graph recipes: No matching entries found for query: GET services
Columns: perf_data metrics check_command
Filter: host_name = [REDACTED]
Filter: service_description = WireGuard wg0 Peer nCnVnG/eLbqu0AS8ROTxehqQ hO/aHNcCOyLQfN15is

"
  }
} 
lpetrora commented 6 months ago

Hi, could you tell me which version of the plugin and which version and edition of checkmk you are using?

airforceixi commented 6 months ago

Apologies, I meant to include that in the first post.

CheckMK Raw 2.1.0p14 Grafana v10.3.3 CheckMK Plugin 3.2.2

airforceixi commented 6 months ago

I updated my CheckMK systems to 2.2.0p23 and changed the checkmk plugin to >=2.2 and it's working now. I guess the change from WebAPI to REST API helped there.

Sorry for the unnecessary issue.

lpetrora commented 6 months ago

Happy to read that.