VolkovLabs / business-text

The Business Text panel plugin allows you to construct a text visualization template from the values of a dataset returned by a data source query.
https://volkovlabs.io
Apache License 2.0
83 stars 13 forks source link

Cannot visualize Prometheus query result. #297

Closed Maltese-Falcon closed 8 months ago

Maltese-Falcon commented 8 months ago

Dynamic Text v4.5.0, Grafana v9.3.2 (disable_sanitize_html = true) - cannot visualize query result.

Attempt 1, display without condition:

  1. PromQL query A: sum by (system_name) (snmp_system_globalstatus{system_name=~"$host"})
  2. PromQL query B: sum by (system_name) (snmp_power_state{system_name=~"$host"})
  3. Under the transformation tab, merge the queries and validate that both are returned as a single row.
  4. Reference in the Content section of the panel:
    <li>{{"Value #A"}}</li>
    <li>{{"Value #B"}}</li>

    No data. According to https://github.com/VolkovLabs/volkovlabs-dynamictext-panel/issues/23 that should work.

Attempt 2, display conditional content:

  1. PromQL query A: sum by (system_name) (snmp_system_globalstatus{system_name=~"$host"}) == bool 3
  2. PromQL query B: sum by (system_name) (snmp_power_state{system_name=~"$host"}) == bool 4
  3. Under the transformation tab, merge the queries and validate that both are returned as a single row.
  4. Reference in the Content section of the panel to display conditional content:
    {{#if (eq "Value #A" True)}}<img class="ok"/>{{else}}<img class="nok"/>{{/if}}
    {{#if (eq "Value #B" True)}}<img class="ok"/>{{else}}<img class="nok"/>{{/if}}

    That doesn't work.

mikhail-vl commented 8 months ago

@Maltese-Falcon Check the returned field names in Inspector or in the json output {{{json @root}}}. They may be called differently that what you are using.

Maltese-Falcon commented 8 months ago

Names are correct: { "data": [ [ { "Time": 1712172240000, "statusColor": "#73BF69", "system_name": "...", "Value #A": 1, "Value #B": 1, "Value #C": 1 } ] ] }

image

image

mikhail-vl commented 8 months ago

@Maltese-Falcon Did you select "Every Row" or other options?

Based on your output, you have data which indicates that you selected one of the other options. In this case you have to work with your fields using data as described in the documentation: https://volkovlabs.io/plugins/volkovlabs-dynamictext-panel/recipes/#iterate-through-all-fields-in-each-record

Screenshot 2024-04-03 at 8 08 47 PM

mikhail-vl commented 8 months ago

@Maltese-Falcon Please read documentation and watch videos to get familiar with the plugin

https://www.youtube.com/watch?v=AcQi-6GCrNU

Maltese-Falcon commented 8 months ago

Thank you.

P.S.: I was able to display conditional content with Render template=Every row and after renamed fields with designations without spaces. I think this is something that should be included in documentation as a separate section.