Grafana is an open-source analytics and interactive visualization web application. Grafana is designed to be a universal dashboard solution. Key aspects of Grafana include:
- Data Source Agnostic
- Customizable Dashboards
- Alerting: a built-in alerting system
- User Management
- Extensibility: supports plugins, enabling users to extend with new data sources, panel types, and app integrations.
Installation
Download page: https://grafana.com/grafana/download?edition=oss
sudo service grafana-server start sudo service grafana-server status sudo systemctl enable grafana-server.service # reboot config # systemctl enable grafana-server # systemctl start grafana-server
Your Grafana server will be hosted at
http://[your Grafana server ip]:3000
The default Grafana login is
- username: admin
- password: admin
If you reboot your server, the Grafana Service may not restart automatically.
You can set the Grafana service to auto restart after reboot by entering,
systemctl enable grafana-server.service
Then, use DNS service to add subdomain such as grafana.he-yulong.com.
Then, set up nginx:
apt install nginx nginx -v service nginx status cd /etc/nginx/sites-enabled vim YOUR-DOMAIN-NAME.conf # grafana.he-yulong.com
like this:
server { listen 80; listen [::]:80; server_name YOUR-DOMAIN-NAME; location / { proxy_set_header Host $http_host; proxy_pass http://localhost:3000/; } # Optional : Allow WSS for Explore Live connections. location /api/ { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; proxy_pass http://localhost:3000/api/; } }
Refresh:
nginx -t service nginx restart service nginx status systemctl enable nginx # set reboot
Test it by visiting again
http://YOUR-DOMAIN-NAME
Add SSH:
We can use a free certificate using the Certbot service.
For Software, choose Nginx
For System, choose Linux (snap)
snap version # check snap install --classic certbot ln -s /snap/bin/certbot /usr/bin/certbot certbot --nginx # he-yulong@outlook.com # Y # N # 1
Done. Certbot already updated the configuration for us (port 443).
cat /etc/nginx/sites-enabled/grafana.he-yulong.com.conf
TestData
fake data to debug.
Query tab features
- The Data source menu
- a panel will usually contain queries from a single data source
- select the Mixed to combine data series from multiple data source
- Query options
- Max data points: Controls the maximum number of data points that should be displayed, even if the time range is very wide.
- Min interval: is used to set the smallest chunk of time or interval Grafana will divide a time range, in order to aggregate all the points in an interval into a representative data point.
- For example, suppose your data is written to a Prometheus database once every minute (the sampling frequency); here, you would set Min interval to 1m.
- Interval: shows Grafana’s calculation for the time period represented by a single data point.
- Time range / max data points (automated)
- Relative time: is used to set the panel time range to one that’s independent of the dashboard time range.
- Time shift: is useful for shifting the panel’s time range to an earlier time by a specified offset from the current time.
- Query inspector: will open a text console, revealing the contents of the query that Grafana submits to the API.
- Query
- Query controls
- Copy icon
- Visibility icon
- Delete icon
- Drag and drop
- +Query: creates a new query below the current one. This query will create a new dataset and display it along with existing queries.
- +Expression: adds a new expression operation to your queries. Even more powerful operations can be performed by creating transformations found under the Transform tab.