Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grafana Cloud unable to upload a grafanalib generated dashboard #549

Open
agilbert314 opened this issue Nov 17, 2022 · 1 comment
Open

Comments

@agilbert314
Copy link

What you expected to happen?

I would expect Grafana Cloud to be able to upload a grafanalib generated dashboard from the button Upload a Dashboard.

What happened?

Grafana Cloud reports the error: Old dashboard JSON format and direct the user to Grafana documentation Read about Importing & Sharing with Grafana 2.x or 3.0.

How to reproduce it?

With this Ptyhon script:

from grafanalib.core import (
  Dashboard, Stat, Target, GridPos, Template, Templating, Time, Repeat
)

application = 'backend'
statusTemplate = Template(default='',
                          dataSource='Prometheus',
                          name='statusCode',
                          multi=True,
                          query=(
                            f'http_server_requests_seconds_count{{'
                            f'application="{application.upper()}",'
                            f'uri=~"/public/api/v1/.*"'
                            f'}}'
                          ),
                          regex='.*status="(\\d+)".*',
                          )

templateList = [statusTemplate]

dashboard = Dashboard(
  title='Some Dashboard',
  timezone='',
  time=Time('now-24h', 'now'),
  panels=[
    Stat(
      title='STATUS $statusCode',
      dataSource=None,
      reduceCalc='lastNotNull',
      repeat=Repeat(direction='h', variable='statusCode'),
      targets=[
        Target(
          expr=(f'round(sum(increase(http_server_requests_seconds_count{{'
                f'status="$statusCode", '
                f'application="{application.upper()}", '
                f'uri=~"/public/api/v1/.*"'
                f'}}[$__range:])))')
        ),
      ],
      gridPos=GridPos(h=6, w=12, x=0, y=0),
    )
  ],
  templating=Templating(list=templateList)
).auto_panel_ids()

With this command line:

generate-dashboard -o grafana_dashboard.json backend.dashboard.py

The JSON dashboard was generated with these versions:

- version
python 3.10
attrs 22.1.0
grafanalib 0.7.0
pip 22.3.1
setuptools 49.2.1
@agilbert314
Copy link
Author

Note that the genarated JSON is supported by grafana version 7.3.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant