Configuring HikariCP for Grafana (in AWS ROSA)

Venkateswaran.N
4 min readMar 18, 2023

--

Introduction

Red Hat OpenShift Service on AWS (ROSA) provides build in container image for Grafana, which provides a dashboard for viewing metrics. This article discusses about configuring connection pool in AWS ROSA environment though the author prefers to use the RDS proxy connection pool over Hikari, for the reasons he explained in this article already.

RDS Proxy Gaps

RDS Proxy is a helpful tool, but like any technology, it has its limitations. One major limitation is that it supports only certain database engines, such as MySQL and PostgreSQL. If you’re using a different database engine, you’re out of luck. Another thing to note is that RDS Proxy doesn’t support all AWS regions.

In terms of scaling, RDS Proxy has its limits. It might not be the best solution for extremely high-traffic applications or databases with very high connection rates. Also, while RDS Proxy can help with read scalability, it may not be as effective for write-intensive workloads.

If you prefer more control over connection pool management, need to support multiple databases, or are not exclusively tied to AWS, HikariCP could be a better choice.

This article assumes that the Amazon RDS database service with mysql and the AWS rosa are already available. Mysql database is used as majority of the users are familiar with.

The deployed Grafana in AWS Rosa should be exposed using the command ‘oc expose svc/grafana’ and url can be obtained using ‘oc get route/grafana’ .

Image courtsy: Fathread.io

Hikari connection pool

HikariCP is a high-performance JDBC connection pool that can be used in Java applications to efficiently manage database connections. To configure HikariCP in Grafana, you can follow the steps below

1. Add HikariCP is to the classpath of your Grafana server by including the HikariCP JAR file in the Grafana plugin directory or adding it to the classpath environment variable.

2. Open the Grafana configuration file located at /etc/grafana/grafana.ini and add the following lines to the [database] section

image 1

3. Save the changes and restart the Grafana server.

4. Once the server is running, use the Grafana UI to create a new data source. Choose the HikariCP data source type from the list of data sources.

5. In the configuration options for the HikariCP data source, enter the database connection details, including the URL, username, password, and other properties.

6. Save the configuration and test the connection to ensure that Grafana is able to connect to the database using the HikariCP connection pool.

All well. We had configured the HikariCP for general deployment. Now let us explore configuring HikariCP in AWS ROSA with three options.

Option 1 — CLI

To configure HikariCP in Grafana on AWS Red Hat OpenShift Service on AWS (ROSA) with an RDS PostgreSQL database, follow the steps below

  1. Open a terminal window and issue the below command
image 2

Lines 8,9 and 10 on the above code gives the connection pool configuration parameters which can be changed based on requirements

2. Create a new service by running the command ‘oc expose svc/grafana’

3. Type and run the command ‘oc get route/grafana’. This will return the grafana dashboard url

Thats it.

OPTION 2 — via Grafana dashboard

The second option to configure HikariCP is via dashboard. Need to do the following steps.

  1. Login the OpenShift web console and navigate to your project.
  2. Click on “Add” button in the left sidebar and select “From Catalog”.
  3. Search for “grafana” in the search bar, and select the “Grafana (Community)” tile.
  4. Click on “Instantiate Template”.
  5. In the “Template Parameters” section, fill in the following parameters
image 3

6. In the “Advanced Options” section, click on “Edit YAML” and modify the YAML code to add the following environment variables

image 4

This adds the required environment variables for HikariCP configuration.

7. Click on “Create” to create your Grafana deployment.

8. Once your deployment is created, Grafana dashboard can be accesed by clicking on the route URL in the “Overview” tab of your deployment. You should now see that HikariCP is being used for the connection pool.

Ssssss……. Life is not as simple as the UI appeared initially.

OPTION 3 — via Cloudformation

The limitation of the above two options are the mandatory redoing those two tasks on every redeployment. To avoid this we can create a cloudformation script and run through the ci/cd pipeline (Tekton, jenkins, etc., ).

image 5 showing the cloudformation portion specific to Hikaricp on ROSA Grafana

Of course, we need to expose service and configure route also for Grafana in cloud formation but we do it the same way we do for other workloads.

Conclusion

Selecting the options depends upon individual’s choice but the experience based recommendation is to go with the cloudformation way. In fact IMO we should externalise the connection pool from our workload service pods and get the connection from there, rather than configuring it in Grafana.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Venkateswaran.N
Venkateswaran.N

Written by Venkateswaran.N

Lead Architect (Application modernization/Containerization - AWS cloud practice , IBM India )

Responses (1)

Write a response