With the G-Core Labs cdn-stats plugin in Grafana, you can display CDN statistics by:
- Total Traffic, which is total traffic volume, consisting of traffic from origin to CDN or Shielding + from Shielding to CDN + from CDN to users;
- Byte cache Hit Ratio, which is the share of cached traffic, calculated using the formula: 1-(traffic from the origin to the CDN or Shielding/traffic from the CDN to users);
- Edges Traffic, which is traffic from CDN, consisting of traffic from Shielding to CDN + from CDN to users;
- Shield Traffic, which is traffic from Shielding to CDN;
- Origin Traffic, which is traffic from the origin, consisting of traffic from the origin to the CDN or from the origin to the Shielding;
- Total Requests, which is the number of requests to the CDN;
- 2xx, 3xx, 4xx, 5xx Responses, which is the number of 2xx, 3xx, 4xx, and 5xx responses;
- Bandwidth, which is bandwidth, calculated based on traffic from the origin to the CDN or Shielding + from Shielding to CDN + from CDN to users;
- Cache Hit Ratio, which is the share of sending cached content, consisting of responses with cached content / requests to CDN;
- Shield traffic ratio is the efficiency of the Shielding: how much more traffic is sent from the Shielding than from the origin, calculated using the formula: (traffic from the Shielding to the CDN - traffic from the origin to the Shielding) / traffic from the Shielding to the CDN;
You can group metrics by the following parameters:
- Clients is for clients;
- Resource is for CDN resources;
- Region is for regions;
- Country is for countries;
- Data is for data centers;
- Vhost is for a personal domain.
Important! The plugin is designed for Grafana version 7.0 and higher.
To configure CDN statistics in Grafana, you need to:
- Use Grafana version 7.0 and higher.
- Download and install the plugin from G-Core Labs.
- Configure the Dashboard for convenient display of information.
Video instructions of the steps:
Download and install the plugin
Download the gcorelabs-cdn-stats-datasource-1.0.8.zip file with the latest version of the plugin in GitHub.
Please, note! The numbers (1.0.8) in the file name indicate the plugin version and may change depending on updates.
Unpack the archive contents to the Grafana plugins folder. By default, this is the Grafana\grafana\data\plugins installation folder
Restart and log in to Grafana.
Click on the gear icon in the menu to open the Configuration section, select Data Sources.
Click Add Data Source to add a new resource for getting data.
Find the cdn-stats plugin from G-Core Labs and click Select to select this plugin.
The plugin settings will be opened. In the Auth section, add a permanent API token.
You can get a token in your personal account. To do this, go to Profile - > API tokens ->Create.
Insert the received API token in the API token field in the format: APIKey {the received API token}.
For example: APIKey 7711$eyJ0eXAiOiJKV
Click Save & Test.
If everything is done correctly, the Datasource updated message and You successfully authenticated as {Name} message will be displayed:
The Download and install the plugin step video instructions
Configure the Dashboard
Click on the " + " in the menu to open the Create section, select Dashboard to add a new dashboard.
In the window that opens, click Add an empty panel to create a new panel.
Make sure that cdn-stats is set as the data source in the Query section.
Select the necessary metric, granularity, and grouping (you can select several).
The Legend field displays the values of the Group by field and the name of the metric by default:
You can customize the output format of the legend data.
Set a name for the metric and in brackets {{}} set the parameters specified in the Group by field.
For example, for the settings above, you can set the following format: Traffic quantity — {{resource}}.
Open the Dashboard settings by clicking on the gear in the upper-right corner.
Go to the Variables section and click Add variable to add a variable. You can use it to filter the data on the chart
For example, to be able to filter resources, you need to make the following settings and click Update:
- In the Name you can specify the variable name (required).
- In the Values for you can select a value for the variable: resourceID (resources).
- In the Sort you can set the sorting order of the elements (optional)
- In the Selection Options you can set the way of how elements can be selected (optional)
- In the Multi-value you can set the abitity to select multiple elements.
- In the Include All option you can set the ability to select all elements by marking the All value.
Go back to the Dashboard by clicking the arrow in the upper-left corner of the screen.
Connect the variable with the Dashboard. To do this, specify its name in the Resources field of the Filters (comma separated) section.
Important! Put $ sign before the variable name.
Now you can choose which resource data is displayed on the chart.
Save the Dashboard. To do this, click Save in the upper-right corner of the panel.