thanos-io / thanos

Highly available Prometheus setup with long term storage capabilities. A CNCF Incubating project.
https://thanos.io
Apache License 2.0
13.15k stars 2.1k forks source link

Provide support for Perses dashboards in Mixins. #7702

Open nicolastakashi opened 2 months ago

nicolastakashi commented 2 months ago

Is your proposal related to a problem?

Perses is an open-source project aimed at simplifying the creation and management of dashboards for observability and monitoring. It offers a more flexible and modern alternative to existing solutions like Grafana.

Recently, Perses was accepted into the CNCF Sandbox, marking a significant milestone for the project. Given this momentum, we believe now is the perfect time to start incorporating support for Perses dashboards into the existing monitoring Mixins.

Currently, Perses dashboards can be created using the Perses GoLang SDK, as we do not support Jsonnet at the moment.

I’d love to hear your thoughts on this approach.

Describe the solution you'd like

(Describe your proposed solution here.)

N/A

N/A

Additional context

N/A

dosubot[bot] commented 2 months ago

Currently, there are no existing integrations or references to Perses in the Thanos codebase or documentation. To add support for Perses dashboards in the Mixins, you would need to create and customize jsonnet files similar to how Grafana dashboards are managed. This involves defining the necessary configurations and selectors for Perses dashboards in the config.libsonnet file and creating specific jsonnet files for each component.

You can follow the existing structure used for Grafana dashboards as a reference. For example, you can look at how dashboards/rule.libsonnet is set up for Grafana and adapt it for Perses. Additionally, you will need to update the jsonnetfile.json to include any dependencies required for Perses.

Here is a basic outline of steps you might take:

  1. Update config.libsonnet: Add configurations specific to Perses dashboards.
  2. Create jsonnet files for Perses dashboards: Similar to dashboards/rule.libsonnet, create jsonnet files for each Thanos component.
  3. Update jsonnetfile.json: Include dependencies required for Perses.

For example, you might add a new section in config.libsonnet:

{
  perses+:: {
    selector: 'job=~".*thanos-perses.*"',
    title: '%(prefix)sPerses' % $.dashboard.prefix,
  },
  // Additional configurations for other components...
}

And create a new jsonnet file for a Perses dashboard, e.g., dashboards/perses.libsonnet:

local g = import '../lib/thanos-perses-builder/builder.libsonnet';
local utils = import '../lib/utils.libsonnet';

{
  local thanos = self,
  perses+:: {
    selector: error 'must provide selector for Thanos Perses dashboard',
    title: error 'must provide title for Thanos Perses dashboard',
    dashboard:: {
      selector: std.join(', ', thanos.dashboard.selector + ['job=~"$job"']),
      dimensions: std.join(', ', thanos.dashboard.dimensions + ['job']),
    },
  },
  persesDashboards+:: {
    [if thanos.perses != null then 'perses.json']:
      g.dashboard(thanos.perses.title)
      .addRow(
        g.row('Perses Metrics')
        .addPanel(
          g.panel('Metric Panel') +
          g.queryPanel(
            'sum by (%(dimensions)s) (rate(thanos_perses_metric_total{%(selector)s}[$__rate_interval]))' % thanos.perses.dashboard,
            '{{ metric }}',
          )
        )
      )
  },
}

This is a simplified example, and you would need to adapt it to fit the specific requirements and structure of Perses dashboards.

To continue talking to Dosu, mention @dosu.

MichaHoffmann commented 2 months ago

Is Perses not compatible with Grafana dashboard JSON definitions?

Nexucis commented 2 months ago

Perses provides a different JSON definition for the dashboard and provides a migration system to convert the Grafana dashboard to the Perses one.

But I would say on a long term, it's better to provide the Perses definition directly. Like @nicolastakashi mentioned, you can code your dashboard with the Go SDK that Perses is providing

Nexucis commented 2 months ago

and FYI, Perses doesn't provide any support for Jsonnet. Only Cuelang or Golang are supported for the moment