grafana / grafonnet

Jsonnet library for generating Grafana dashboards.
https://grafana.github.io/grafonnet/
Apache License 2.0
352 stars 19 forks source link

Support Influxdb #147

Open lohrm-stabl opened 11 months ago

lohrm-stabl commented 11 months ago

Currently, there are no query target helpers/functions (not sure what the correct terminology is) for InfluxDB InfluxQL nor InfluxDB Flux. It would be great to have them at least for InfluxQL, as this data source is quite popular.

The way it has to be done right now:

+ g.panel.timeSeries.queryOptions.withTargets([
        time.queryOptions.withDatasource('influxdb', influxFluxDataSource)
        + {
          alias: 'Frequency',
          groupBy: [
            {
              params: [
                '$__interval',
              ],
              type: 'time',
            },
            {
              params: [
                'none',
              ],
              type: 'fill',
            },
          ],
          measurement: 'telemetry_v2',
          orderByTime: 'ASC',
          policy: 'default',
          query: '',
          refId: 'A',
          resultFormat: 'time_series',
          select: [
            [
              {
                params: [
                  'system_frequency_freq_hz',
                ],
                type: 'field',
              },
              {
                params: [],
                type: 'mean',
              },
            ],
          ],
          tags: [
            {
              key: 'device_id',
              operator: '=~',
              value: '/^$device$/',
            },
          ],
        },
      ])
Duologic commented 10 months ago

This would be a nice library but currently we haven't figured out the flow to create libraries for plugins, we'll keep this open as we're looking for possible solutions.