Step 1: Create table in postgresql and insert data in it to visualize on dashboard panel.
Step 2: Create new dashboard and select table visualization
Step 3 : Add variables to filter the data
Create the Variables in Grafana
To filter and visualize your fruit data, you’ll need to create variables for dynamic dropdowns (Fruit Type, Fruit Subtype, and Fruit Details).
3.1 Create Level 1 Variable (Fruit Type)
- Go to Dashboard Settings → Variables → Add Variable.
- Configure the following:
- Name : Level_1_Fruit
- Type : Query
- Data Source : Select your PostgreSQL data source.
- Query :
sql
CopyEdit
SELECT DISTINCT “level_1_fruit_information” FROM fruits
- Refresh : On Dashboard Load
- Include All option : Enabled (if you want to allow “All” option).
- Click Save.
3.2 Create Level 2 Variable (Fruit Subtype)
- Go to Dashboard Settings → Variables → Add Variable.
- Configure the following:
- Name : Level_2_Fruit
- Type : Query
- Data Source : Select your PostgreSQL data source.
- Query :
sql
CopyEdit
SELECT DISTINCT “level_2_fruit_information” FROM fruits
WHERE “level_1_fruit_information” = ‘$Level_1_Fruit’
- Refresh : On Variable Change
- Include All option : Enabled (optional).
- Click Save.
- 3.3 Create Level 3 Variable (Fruit Details)
- Go to Dashboard Settings → Variables → Add Variable.
- Configure the following:
- Name : Level_3_Fruit
- Type : Query
- Data Source : Select your PostgreSQL data source.
- Query :
sql
CopyEdit
SELECT DISTINCT “level_3_fruit_information” FROM fruits
WHERE “level_2_fruit_information” = ‘$Level_2_Fruit’
- Refresh : On Variable Change
- Include All option : Enabled (optional).
- Click Save.
- Step 4 : Fetch data using these query to show data on grafana
Final output