| --- |
| title: "Grafana User Guide" |
| sidebar_position: 2 |
| description: > |
| Grafana User Guide |
| --- |
| |
| |
| # Grafana |
| |
| <img src="https://user-images.githubusercontent.com/3789273/128533901-3107e9bf-c3e3-4320-ba47-879fe2b0ea4d.png" width="450px" /> |
| |
| When first visiting Grafana, you will be provided with a sample dashboard with some basic charts setup from the database. |
| |
| ## Contents |
| |
| Section | Link |
| :------------ | :------------- |
| Logging In | [View Section](#logging-in) |
| Viewing All Dashboards | [View Section](#viewing-all-dashboards) |
| Customizing a Dashboard | [View Section](#customizing-a-dashboard) |
| Dashboard Settings | [View Section](#dashboard-settings) |
| Provisioning a Dashboard | [View Section](#provisioning-a-dashboard) |
| Troubleshooting DB Connection | [View Section](#troubleshooting-db-connection) |
| |
| ## Logging In<a id="logging-in"></a> |
| |
| Once the app is up and running, visit `http://localhost:3002` to view the Grafana dashboard. |
| |
| Default login credentials are: |
| |
| - Username: `admin` |
| - Password: `admin` |
| |
| ## Viewing All Dashboards<a id="viewing-all-dashboards"></a> |
| |
| To see all dashboards created in Grafana visit `/dashboards` |
| |
| Or, use the sidebar and click on **Manage**: |
| |
|  |
| |
| ## Importing a Dashboard<a id="importing-a-dashboard"></a> |
| If you want to import a dashboard to Grafana which you have backed up earlier, please follow the steps below: |
| |
| 1. Click the `Import` icon |
| 2. Click the `Upload JSON file` button |
| 3. If the dashboard conflicts with an existing one, please change the `Name` and `uid` |
| 4. Click `Import` |
| |
|  |
| |
| |
| ## Customizing a Dashboard<a id="customizing-a-dashboard"></a> |
| |
| When viewing a dashboard, click the top bar of a panel, and go to **edit** |
| |
|  |
| |
| **Edit Dashboard Panel Page:** |
| |
|  |
| |
| ### 1. Preview Area |
| - **Top Left** is the variable select area (custom dashboard variables, used for switching projects, or grouping data) |
| - **Top Right** we have a toolbar with some buttons related to the display of the data: |
| - View data results in a table |
| - Time range selector |
| - Refresh data button |
| - **The Main Area** will display the chart and should update in real time |
| |
| > Note: Data should refresh automatically, but may require a refresh using the button in some cases |
| |
| ### 2. Query Builder |
| Here we form the SQL query to pull data into our chart, from our database |
| - Ensure the **Data Source** is the correct database |
| |
|  |
| |
| - Select **Format as Table**, and **Edit SQL** buttons to write/edit queries as SQL |
| |
|  |
| |
| - The **Main Area** is where the queries are written, and in the top right is the **Query Inspector** button (to inspect returned data) |
| |
|  |
| |
| ### 3. Main Panel Toolbar |
| In the top right of the window are buttons for: |
| - Dashboard settings (regarding entire dashboard) |
| - Save/apply changes (to specific panel) |
| |
| ### 4. Grafana Parameter Sidebar |
| - Change chart style (bar/line/pie chart etc) |
| - Edit legends, chart parameters |
| - Modify chart styling |
| - Other Grafana specific settings |
| |
| ## Dashboard Settings<a id="dashboard-settings"></a> |
| |
| When viewing a dashboard click on the settings icon to view dashboard settings. Here are 2 important sections to use: |
| |
|  |
| |
| - Variables |
| - Create variables to use throughout the dashboard panels, that are also built on SQL queries |
| |
|  |
| |
| - JSON Model |
| - Copy `json` code here and save it to a new file in `/grafana/dashboards/` with a unique name in the `lake` repo. This will allow us to persist dashboards when we load the app |
| |
|  |
| |
| ## Provisioning a Dashboard<a id="provisioning-a-dashboard"></a> |
| |
| To save a dashboard in the `lake` repo and load it: |
| |
| 1. Create a dashboard in browser (visit `/dashboard/new`, or use sidebar) |
| 2. Save dashboard (in top right of screen) |
| 3. Go to dashboard settings (in top right of screen) |
| 4. Click on _JSON Model_ in sidebar |
| 5. Copy code into a new `.json` file in `/grafana/dashboards` |
| |
| ## Troubleshooting DB Connection<a id="troubleshooting-db-connection"></a> |
| |
| To ensure we have properly connected our database to the data source in Grafana, check database settings in `./grafana/datasources/datasource.yml`, specifically: |
| - `database` |
| - `user` |
| - `secureJsonData/password` |
| |
| |
| ## Troubleshooting |
| |
| If you run into any problem, please check the [Troubleshooting](/Troubleshooting/Dashboard.md) or [create an issue](https://github.com/apache/incubator-devlake/issues) |