Skip to content

GrafanaExporter is a utility program for saving batches of chart .PNG images from specific Grafana dashboard with configured grafana-image-renderer plugin.

Notifications You must be signed in to change notification settings

AnaxRho/GrafanaExporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GrafanaExporter

Introduction

GrafanaExporter is a utility program for saving batches of chart .PNG images from specific Grafana dashboard with configured grafana-image-renderer plugin.

[RU] Утилита для сохранения PNG изображений графиков с определенного дашборда Grafana с настроенным плагином Grafana Image Renderer.

GrafanaExporter uses grafana-image-renderer-provided HTTP API interface to download and save chart images.

Download URL for Grafana with grafana-image-renderer example: http://grafana_host:3000/render/d-solo/PS4sLaC7z/sample-dashboard?panelId=1&from=now-1h&to=now&theme=light&width=1000&height=500&tz=Europe%2FMoscow&timeout=120

CLI

Usage: java -jar GrafanaExporter.jar [options]

Options:

Option Type Description
--config, -c Required Path to GrafanaExporter XML configuration file
--from, -f Required Value to use as time range 'from' part for charts.
Absoulute, relative, unixtime should work. See documentation.
--to, -t Required Value to use as time range 'to' part for charts. Value format is the same as above.
--concurrency Optional Number of concurrent downloads. Default: 1
--destination, -d Optional Destination path for saving images files. Overrides destination specified in XML configuration file
--prefix, -p Optional Prefix to add to all file names specified in XML configuration file
--help, -h Optional Show usage help

Run Examples

YYYY-MM-DD'T'HH24:MI:SS time format:

    java -jar GrafanaExporter.jar --config C:\config.xml --from 2020-01-01T10:00:00 --to 2020-01-01T11:00:00

Relative time:

    java -jar GrafanaExporter.jar -c C:\config.xml -f now-1h -t now

Epoch millis time:

    java -jar GrafanaExporter.jar -c C:\config.xml -f 1655308790000 -t 16553087960000

XML config

Config example

<Configuration>
    <Host>http://myhost:3000</Host>
    <Dashboard>sample-sashboard</Dashboard>
    <DashboardUID>SSVf6YRWk</DashboardUID>
    <ApiKey>AQ==</ApiKey>
    <Destination>C:\out</Destination>
    <Timezone>Europe/Moscow</Timezone>
    <Timeout>120</Timeout>
    <Param name="theme">light</Param>
    <Panel>
        <PanedId>1</PanedId>
        <Name>cpu_usage</Name>
        <Folder>myhost</Folder>
        <Width>1000</Width>
        <Height>500</Height>
        <Var name="host">myhost</Var>
    </Panel>
    <Panel>
        <PanedId>1</PanedId>
        <Name>cpu_usage</Name>
        <Folder>myhost</Folder>
        <Width>1000</Width>
        <Height>500</Height>
        <Var name="host">myhost2</Var>
    </Panel>
    <Panel>
        <PanedId>2</PanedId>
        <Name>mem_usage</Name>
        <Folder>myhost</Folder>
        <Width>1000</Width>
        <Height>500</Height>
        <Var name="host">myhost</Var>
    </Panel>
    <Panel>
        <PanedId>2</PanedId>
        <Name>mem_usage</Name>
        <Folder>myhost</Folder>
        <Width>1000</Width>
        <Height>500</Height>
        <Var name="host">myhost2</Var>
    </Panel>
</Configuration>

Root XMLElement Configuration

XML Element Type Occurrence Description
Host String {1} Grafana base URL.
Example: http://localhost:3000
Dashboard String {1} Dashboard name.
Example: http://localhost/grafana/d/5FGhJhv4z/sample-sashboard?orgId=1
DashboardUID String {1} Dashboard unique ID.
Example: http://localhost/grafana/d/5FGhJhv4z/sample-sashboard?orgId=1
ApiKey String {1} Grafana API key. See documentation
Destination String {1} Destination directory to save images. Example: C:\out
Timezone String {0, 1} Timezone. Example: Europe/Moscow
Timeout Integer {0, 1} Timeout for downloads. Example: 120
Param Array {0,} Array of Grafana params to pass in %name%=%value% format. Examples: theme=light
Var Array {0,} Array of Grafana variables to pass in var-%name%=%value% for dashboard variables. Examples: var-host=myhost
Panel Array of 'Panel' element {0,} List of panel specific information.

Child Element Graph

XML Element Type Occurrence Description
PanedId String {1} Id of dashboard panel.
Example: http://localhost/grafana/d/5FGhJhv4z/sample-sashboard?viewPanel=1&orgId=1
Name String {1} Name for chart image file. Example: cpu_usage_myhost
Folder String {0,1} Subfolder to save image to. Example: myhost
Width Integer {1} Image width in pixes. Example: 1000
Height Integer {1} Image height in pixes. Example: 500
Param Array {0,} Array of Grafana params to pass in %name%=%value% format. Examples: theme=light
Var Array {0,} Array of Grafana variables to pass in var-%name%=%value% for dashboard variables. Examples: var-host=myhost

About

GrafanaExporter is a utility program for saving batches of chart .PNG images from specific Grafana dashboard with configured grafana-image-renderer plugin.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages