Skip to content

It is a chatbot that can be used for search graphs and KPIs in Grafana with desired time range directly don't need to login search through Dashboards

Notifications You must be signed in to change notification settings

arashxmohammadi/Grafana-Chatbot

Repository files navigation

Grafana Chat Bot

A Python-based chatbot that connects to Grafana for searching graphs and KPIs, with customizable time ranges.

Setup Instructions

  1. Install Python dependencies:

    pip install -r requirements.txt
  2. Configure Grafana Connection:

    To generate a Grafana API key:

    • Log into your Grafana instance
    • Go to Configuration > API Keys
    • Create a new API key with "Admin" role
    • Copy the generated key to .env file
  3. Start the server:

    python main.py

API Endpoints

  • GET /: Health check endpoint
  • POST /search: Search for graphs and KPIs
    • Parameters:
      • query: Search term
      • time_from: Start time (optional, default: now-6h)
      • time_to: End time (optional, default: now)
  • GET /render/{dashboard_uid}/{panel_id}: Render panel image
    • Parameters:
      • dashboard_uid: Dashboard UID
      • panel_id: Panel ID
      • time_from: Start time (optional)
      • time_to: End time (optional)

Time Range Formats

Supported time range formats:

  • Relative: now-6h, now-1d, now-1w
  • Absolute: 2023-01-01, 2023-01-01 13:00:00

Example Usage

  1. Search for CPU metrics:

    curl -X POST "http://localhost:8000/search" \
      -F "query=CPU" \
      -F "time_from=now-1h" \
      -F "time_to=now"
  2. Render a specific panel:

    curl "http://localhost:8000/render/{dashboard_uid}/{panel_id}?time_from=now-1h&time_to=now"

About

It is a chatbot that can be used for search graphs and KPIs in Grafana with desired time range directly don't need to login search through Dashboards

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published