Grafana
Grafana
It supports various data types, and as it is freeware, we can assure that the
moment a new data source has been released, someone will support it. The most
general use case of Grafa is visualizing the time series data, like CPU over time
or memory.
We can host the Grafana ourselves through the Managed Services in AWS or use
Creators for hosting for you. Grafana executes the process on our server or
computer, and we can access the interface through our browser. The dashboard can
display the data as graphs, heat maps, single numbers, or charts.
If you want to enrich your career and become a professional in Grafana, then enroll
in "Grafana Online Training" - This course will help you to achieve excellence in
this domain.
Install Grafana Locally
The steps for installing Grafana depend on where we run the Grafana. We regularly
run this kind of application locally to see how it works before running remotely.
It offers detailed instructions for wherever we need to deploy it.
We can install it on different operating systems. Following are some hardware and
software requirements:
Hardware Requirements
Grafana needs a database for storing its configuration data like data sources,
dashboards, and users. It supports the below databases:
MySQL
SQLite
PostgreSQL
Step2: Login
Open the web browser and open “http://localhost:3000/”. The default HTTP port that
Grafana listens to is 3000 until we have configured the data port.
On the login page, type “admin” for username and password.
Press Log in. If login is successful, we will see the prompt for changing the
password.
Press OK on prompt, next modify your password.
Use Homebrew for installing the recent version of the Grafana through the Homebrew
package.
Step1: On the Homebrew homepage, search for Grafana. The latest version of Grafana
is listed.
brew update
brew install grafana
Brew page downloads and goes into the following files
Step1: Choose the Grafana version we have to install. By default, the latest
version is chosen.
Step4: Open the terminal and download the binary file through the cURL command. The
following command displays Grafana 7.1.5 version:
Curl -0 https://d1.grafana.com/oss/release/grafana-7.1.5.darwin-amd64.tar.gz
Step5: Enter the “gz” file and copy files to a location of our preference.
Step6: For Starting the Grafana service, open the directory and execute the
command:
./bin/grafana-server web
Configuring our Data Source
Configuring the data source is the first step in building Grafan dashboards. Our
data source can be the database or the collection of logs. It supports various data
sources from traditional data sources MySQL to the log aggregation platforms like
the AWS Cloudwatch.
Now we will configure the Grafana for connecting to our MySQL database. For
instance, I have created the database named “CD” with the table known as “Artist”
for simulating the database of an application.
Now, we have to add the Grafana user to the database. In MySQL database, the
database administrator will execute the following for adding the read-only user
with name “GrafanaReader” to our database “CD” for table “Artist.”
For adding the link from our database to the Grafana, go back to the Grafana
interface.
The first option below is “Create our first data source” Complete the web form with
our connection details. Complete web form with connection details. If we are using
the local MySQL database running on the localhost on port 3306 for database “CD”
and with the user name “GrafanaReader,” It is safe to leave the remaining fields as
default.
Press save and test. If we configured everything correctly, we must see the green
box with the message “Database Connection OK.”
Creating Dashboards
A Dashboard offers you a detailed view of the data and allows us to track the
measures using different visualizations. Dashboards contain panels that represent a
part of the story we want our dashboard to convey. The intent of the Grafana
dashboard is to bring the data together in a way that is both organized and
efficient.
It enables the users to understand the measure of our data using queries, detailed
visualizations, and alerts. Grafana also helps us share the dashboards with others,
enabling us to analyze the data together.
Another important feature of Grafana dashboards is freeware, which enables for more
power and personalization, subject to how affluent with coding. Yet, we do not
require comprehensive knowledge of coding for creating our completely working
dashboards.
Each panel contains a visualization and a query. The query specifies what data we
have to display, while the visualization specifies how we show the data.
Step1: In the sidebar, hover the cursor on the “create” icon and next press
“Download.”
Step3: In Query Editor of the graph, type the query from earlier, and next click
“Shift+Enter”:
Step4: In the “Legend” field, type “route” for renaming the time series in the time
legend. Graph legend updates when we press outside the field.
Step5: In the Panel editor of right, in Settings, modify the panel title to the
“Traffic.”
Step6: Press “Apply” in the top-right corner to save the panel and revert to the
dashboard view.
Step7: Press the “Save Dashboard” icon at the top of the dashboard for saving our
dashboard.
Step8: Enter the name in the “New Name” field and next press “save.”
Step2: Discover the “plugins” property in the Grafana configuration file and set
“plugins” property to the path of our “grafana-plugin” directory.
Plugins = “/path/to/grafana-plugins”
Step3: Restart the Grafana if it is already working for loading the new
configuration.
Step1: In Plugin Directory, Create the plugin from the template through the
“plugin: create” command:
cd my-plugin
Step3: Download the required dependencies:
yarn install
Step4: Develop the plugin
yarn dev
Step5: Restart the Grafana server for Grafana for discovering our plugin.
Step6: Open the Grafana and go to the “Configuration/Plugins.” Assure that your
plugin exists.
Grafana Queries
Grafana supports more than 26 queries per panel. Grafana relies on the appropriate
query language for the data source. That can be Prometheus SQL, InfluxQL, PromQL,
PostgreSQL’s SQL variant, Elasticsearch Query DSL, InfluxQL, etc.
In the query selection tab of Grafana’s UI, we can select the data source to use.
It will show whatever data sources we already associated with our iteration of the
Grafana. We can choose the mixed option to query from multiple sources
simultaneously.
“Query” method
The query method is the core of every data source plugin. It receives the query
from the user, gets the data from the external database, and gets the data in the
format that Grafana identifies.
The “Options” object includes the targets or queries that we made, along with the
environment data, along with the background data, like the current time interval.
We will use this information to query the external database
Prometheus Grafana
Prometheus is a freeware data monitoring tool. The combination of Grafana and
Prometheus is the de facto tool combination used for deploying the data
visualization environment. We use Grafana Dashboards to visualize the data while
the backend is controlled by the Prometheus. Although Prometheus also has data
visualization features, yet, Grafana is chosen for visualizing the data. Prometheus
is suitable to store the time series data.
Conclusion
Our Grafana helps you install and configure the Grafana. It also enables you to
create dashboards and plugins. I hope this information is sufficient for getting
the fundamental idea about Grafana. If you have any queries, let us know by
commenting below.