grafana-checkmk-datasource icon indicating copy to clipboard operation
grafana-checkmk-datasource copied to clipboard

Hostname in title (RAW edition)

Open jplitza opened this issue 2 years ago • 11 comments

When using the plugin with the RAW edition, before plugin version 2.0 I could use multiple queries on different hosts in a single graph. Now, all data frames have the same name (e.g. "Input bandwidth" and "Output bandwidth", each repeated once for every host).

I hacked around this using the following:

--- a/src/DataSource.ts
+++ b/src/DataSource.ts
@@ -24,7 +24,7 @@ function buildMetricDataFrame(response: any, query: MyQuery) {
   const frame = new MutableDataFrame({
     refId: query.refId,
     fields: [{ name: 'Time', type: FieldType.time }].concat(
-      curves.map((x: any) => ({ name: x.title, type: FieldType.number }))
+      curves.map((x: any) => ({ name: get(query, "context.host.host") + "," + x.title, type: FieldType.number }))
     ),
   });
   zip(...curves.map((x: any) => x.rrddata)).forEach((d: any, i: number) =>

However, this most definitely isn't a proper solution, because it will probably break Enterprise Editions.

jplitza avatar May 24 '22 10:05 jplitza

Thanks for the report, this is indeed a problem.

2022-05-25_16-29

We discussed this internally and came up with a possible solution: provide an optional text input field to configure the legend of the graph. Perhaps it would also be useful to be able to choose from different variables as $hostname, $service, $metric or similar.

We are currently not sure when we will be able to implement this feature, please be patient with us.

BenediktSeidl avatar May 25 '22 14:05 BenediktSeidl

hey @jplitza i replaced the line to + curves.map((x: any) => ({ name: get(query, "context.host.host") + "," + x.title, type: FieldType.number }))

but still looks the same, without hostname

kobid84 avatar Jul 29 '22 22:07 kobid84

@BenediktSeidl any news with this issue ? we cannot upgrade checkmk version because of this..

kobid84 avatar Aug 10 '22 19:08 kobid84

No news yet. I fear it will still take some time to implement this. But I just tried the diff from jplitza, and it works just fine. It's not enough to simply change the line, but you have to rebuild the plugin after changing the line. This can be done by yarn install, then yarn build.

BenediktSeidl avatar Aug 16 '22 08:08 BenediktSeidl

I'm experiencing the same issue, I haven't tested the diff yet but I'd definitely appreciate an official solution. But other than that the plugin is really great, thank you!

iandk avatar Sep 19 '22 09:09 iandk

I hope this will be implemented. This would be great, maybe "Hostname - Service" would be great. Something like this:

image

michaelortnersanube avatar Nov 09 '22 05:11 michaelortnersanube

This command should patch the compiled version directly (now with the schema $HOST - $SERVICE - $TEMPLATE)

sed -i 's#\(refId:\(.\)\.refId,.*{name:\)\(.\.title\)#\1(\2.context.host||{}).host+" - "+(n.context.service||{}).service+" - "+\3#' dist/module.js

EDIT: Updated for version 3.1.0 (which has two backends and hence requires two patches):

sed -i -e 's#getGraphQuery(.,\(.\)).*=>({name:#\0\1.requestSpec.host_name+" - "+\1.requestSpec.service+" - "+#' -e 's#getSingleGraph(.,\(.\)).*\.push({name:#\0\1.requestSpec.host_name+" - "+\1.requestSpec.service+" - "+#' module.js

jplitza avatar Dec 16 '22 09:12 jplitza

Hello, we are a customer of the checkmk enterprise version... when will the feature be implemented... without that its nearly impossible to build custom network graphs as they have all the same name :/

LMSBrubaker avatar Jul 11 '23 09:07 LMSBrubaker

Hi @LMSBrubaker,

user of the enterprise version should not have this problem as you can use the regular expression for filtering hosts or sevices. This problem only occurs for users forced to use multiple queries in a Panel containing the same service names.

Independent of this side note: We just finished two big projects for the plugin. The following moves will be some clean up to our code as we want the plugin to be maintainable. This includes some bug fixing and fixing of other issues. As we have already an approach on how to handle the metric naming, we can do that either during this maintenance phase or shortly after. We are aware of this issue and we will work on a solution as fast as possible. Currently, it only depends on our prioritization regarding other issues/bugs, we want to fix.

godspeed-you avatar Jul 11 '23 13:07 godspeed-you

hi @BenediktSeidl any updates with this issue? I'm afraid to upgrade checkmk to latest version.

kobid84 avatar Oct 02 '23 12:10 kobid84

@lpetrora did the first step to overcome this issue: 5b35a6d8c5ba252a8f9aa414df533e1ce1cdbb5f this should be usable with the current version 3.2.2b1. feedback is welcome. this change allows you to work around the issue mentioned in this ticket. the next step is to adapt checkmk to provide meta-data for the graph, so you can not only use data specified in the filter. for example It's currently not possible to use a host variable in the label if you fetch your hosts with a host regex filter. but this has to be changed in checkmk which takes some time.

BenediktSeidl avatar Feb 13 '24 07:02 BenediktSeidl