How to use grafanalib for athena data source?

Hello,

I am trying to replicate an existing dashboard panel using the grafanalib api in python.
I am stumbled at the doc as it doesnt seem to explain how i can input my query

This is the code i have that generates the panel json which then i upload

dashboard = Dashboard(
    title="Test Dashboard",
    description="Python code generated Dashboard",
    tags=[
        'test'
    ],
    timezone="browser",
    panels=[
        Stat(
            title='Resolved alerts',
            dataSource='Amazon Athena',
            description='Number alerts that has been resolved',
            format='table',
            transparent=True,
            targets=[
                Target(
                    datasource='AwsDataCatalog',
                    format=1,
                    expr="SELECT count(*) FROM pd_alert WHERE status='resolved'",
                    refId="A",
                ),
            ],
            gridPos=GridPos(h=8, w=16, x=0, y=0),
        ),
    ],
).auto_panel_ids()

Can someone point out how i can include the athena query expression for a panel of Stat type?

I also tried backtracking from the json model of the existing panel but the fields are not consistent

Thank you

Hello,

Might get a quicker answer over at

As it is not a grafana product.

Sure, thanks for pointing the resources

@yosiasz apart from grafanalib is there any other way we could generate dashboards using code?

Could we use the json model of the panel to make a curl call maybe ?

1 Like