Grafana integration
Published: 2023-08-09 12:31:15

## Introduction

We are excited to announce that **Manticore Search** starting from [6.2.0](https://manticoresearch.com/install/) integrates effortlessly with **Grafana**, the popular open-source data visualization and monitoring platform. By leveraging the default MySQL connector, you can now visualize Manticore Search data in a more dynamic and informative way. This integration brings new possibilities for search performance optimization, trend analysis, and real-time insights.

In the following sections, we will guide you through the process of connecting Manticore Search to **Grafana** and help you create your first chart.

## Step-by-step tutorial

### Step 1: Install and Configure Manticore Search

Before connecting **Manticore Search** to **Grafana**, make sure you have installed and configured **Manticore Search** on your server. Follow the [official Manticore Search documentation](https://manual.manticoresearch.com/Installation/Installation) for installation and setup instructions.

### Step 2: Set up Grafana

To set up Grafana, follow the official [Grafana installation guide](https://grafana.com/docs/grafana/latest/setup-grafana/installation/).

### Step 3: Prepare Manticore Search data to visualize

In the next step, you need to prepare and create tables in Manticore Search, then load them with data that will help us generate charts and visualize them using Grafana. Connect to Manticore using a MySQL client and execute the following queries:

Here is the structure we will use:

```sql
CREATE TABLE btc_usd_trading (
id bigint,
time timestamp,
open float,
high float,
low float,
close float
);
```

Now, let's add some data to populate the table. Just open your terminal and run following comands:

```bash
curl -sSL https://gist.githubusercontent.com/donhardman/df109ba6c5e690f73198b95f3768e73f/raw/0fab3aee69d7007fad012f4e97f38901a64831fb/btc_usd_trading.sql | mysql -h0 -P9306
```

### Step 4: Connect Manticore Search to Grafana

![Connect via MySQL](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qo5ojwccomopl50poauq.png)

1. Log in to your **Grafana** dashboard and click on "Configuration" (the gear icon) in the left sidebar.
2. Select "Data Sources" and click on "Add data source."
3. Choose "MySQL" from the list of available data sources. ![MySQL connection settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kvdlw8rwykg8ecd5ej69.png)
4. In the settings page, provide the following details:
    - Name: A name for the data source (e.g., "Manticore Search").
    - Host: The hostname or IP address of your Manticore Search server.
    - Database: Your Manticore Search database name.
    - User: The username with access to the specified Manticore Search database.
    - Password: The password for the specified user.
5. Click on "Save & Test" to verify the connection.

### Step 5: Create a Dashboard and Add a Chart

1. In the Grafana dashboard, click on the "+" icon in the left sidebar, and select "New dashboard." ![New Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3wnm1qn40qzaj7mrsrbm.png)
2. Click on the "Add visualization" button to start configuring your chart. ![Add visualization](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f1zxmbyn4jlblleu119h.png) 
3. Choose the datasource with Manticore Search that connected by using MySQL connector. ![Select Data Source](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nancku56zdbzhlqx4elt.png)
4. Choose the type of chart you want to create (e.g., bar chart, line chart, pie chart) from the list of available visualization options. We will choose “Time Series”. ![Choose type of chart](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j02y3jrsbhorxfhy1bya.png)

### Step 6: Configure the Chart

1. Use Grafana's query builder or simply write an SQL query to fetch the data you want to visualize from your Manticore Search database.
2. Customize the chart's appearance, labels, and other settings as needed.
3. Click on "Apply" to save your chart. ![Chart query settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oqmvy3k4aq5kknw2qzat.png)

### Step 7: Check your chart’s result

Here is a sample of the results we obtained by using the provided data.

![Time Series result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jqgraa4rvf0nppsv8d5b.png)

It's easy to change the style of a chart, as in this example, we used Bitcoin prices. Simply choose Candlestick and adjust the query builder by selecting all fields. This will provide an entirely different view of your data in **Grafana**.


![Candlestick chart type](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7zt9hac4matq62tcskkg.png)
![Candlestick query setting](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iiz0x9lzv1z8430v75l0.png)
![Candlestick result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/315qhwm5a3nttzjp52zf.png)

You can also use different types of visualizations available in **Grafana**, depending on the data in your **Manticore Search** database. Simply connect your Manticore Search, select the table, and create a chart with the desired parameters using the default MySQL connector.

Build your own dashboard by combining different charts of your data!


![Dashboard Example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ftrwoz8n5gs1k4s38fi.png)

## Conclusion

With the seamless integration of **Manticore Search** and **Grafana** using the default MySQL connector, you can now unlock the full potential of your search data. Visualize trends, performance metrics, and real-time insights with ease, all within the intuitive **Grafana** interface. Get started today and elevate your data analysis capabilities to new heights.