Using Grafana to create a Dashboard from a local Mendix Application Data

Vinicius Strugata Ambrosio
4 min readDec 30, 2023

--

Photo by Stephen Dawson on Unsplash

In my last article, we stopped in the Prometheus configuration, commenting that there is a better option to create Dashboards: Grafana. This time, I present here the basic procedure for using Grafana to create a simplified Dashboard showing data from a Mendix-created application, connecting to the Prometheus data source.

Procedure

[0] Follow the procedure described in the previous article, since we will continue from it.

[1] Download and install the Grafana application in your Operational System. For Windows, follow these instructions.

[2] Start Grafana, preferably via the command line, to see the logs. Here I’m using a PowerShell script to start:

<your installation path>\grafana-v10.2.3\bin\grafana.exe

[3] Access the URL http://localhost:3000 to access the Grafana application. Enter the credentials: user admin and password admin . The app will ask you to provide new credentials, you can change them or skip this configuration for now.

[4] You first have to create a connection with the Prometheus. Here is presented the basic configuration. For details, please consult the Grafana documentation. Click on the hamburger menu, then Connections/Add new connection.

Grafana Hamburger menu

[5] Search for Prometheus and click on the first result shown:

Grafana provides Prometheus integration

[6] Give a suitable name to this connection. Also, inform the Prometheus URL: http://localhost:9090

Prometheus integration basic configuration

[7] All the other settings can be left as is. Scroll down and click on the Save & test button. If all is OK, you should see a green success message:

Prometheus integration Success Message

[8] Now let’s create our simplified Dashboard. In the hamburger menu, click on Dashboards and then on the New/New dashboard button

New Dashboard button

[9] In the Dashboard, we can add Visualization Panels, that can be used to monitor the metrics from our Mendix-created application. These metrics can be custom or use one from the List of Metrics. To add a visualization panel, click on the Add/Visualization button in the toolbar:

Add/Visualization Menu

[10] The full procedure to configure the visualization panels is beyond the scope of this article. It’s well documented in the Grafana documentation. You should select the visualization type and the query, as shown below:

Grafana visualization configuration, using a metric automatically provided by Mendix

[11] After some configuration, we can easily reach this Dashboard result, suitable for our Mendix-created Application:

Dashboard showing the custom metrics and also session metrics
Dashboard showing runtime metrics and system metrics (JVM)

Here are the queries used for creating these visualizations:

# Named Users Sessions; Type Stat
# Query:
mx_runtime_stats_sessions_named_user_sessions{instance="localhost:8090", job="mendix"}

# Named Users Sessions; Type Stat
# Query:
mx_runtime_stats_sessions_named_users{instance="localhost:8090", job="mendix"}

# Anonymous Sessions; Type Stat
# Query:
mx_runtime_stats_sessions_anonymous_sessions{instance="localhost:8090", job="mendix"}

# Rate of Total Requests: Type Time Series
# Query
irate(mx_runtime_stats_requests_total{instance="localhost:8090", job="mendix"}[1h])

# Rate of Total Transactions: Type Time Series
# Query
irate(mx_runtime_stats_connectionbus_transactions_total{instance="localhost:8090", job="mendix"}[1h])

# Rate of Total Selections: Type Time Series
# Query
irate(mx_runtime_stats_connectionbus_selects_total{instance="localhost:8090", job="mendix"}[1h])

# Rate of Total Deletes: Type Time Series
# Query
irate(mx_runtime_stats_connectionbus_deletes_total{instance="localhost:8090", job="mendix"}[1h])

# JVM Memory: Type Time Series
# Query
jvm_memory_used_bytes

Conclusion

Grafana is an amazing tool for creating Dashboards. In this article, we just scratched the surface of the possibilities this tool offers. It’s very easy to integrate with Mendix-created applications so that we have a chance to create and test Dashboards locally, avoiding doing this configuration directly on the Environment.

But I’m aware this is not yet the best setup for monitoring a Mendix Application. Installing each component manually is not a smart decision, considering that we can create a Docker Compose file that installs and configures all of them automatically for us, with the additional benefit that we can create different scenarios (varying the Database, memory, etc) and use the Dashboards readings to analyze, correct and optimize our applications.

This is the subject of the next article: Docker with Prometheus, Grafana, and Mendix. So stay tuned and see you in 2024. Happy New Year to all developers of the World!

--

--

Vinicius Strugata Ambrosio
Vinicius Strugata Ambrosio

Written by Vinicius Strugata Ambrosio

Mendix Developer, Python Enthusiast and Flutter/Dart Learner — https://www.linkedin.com/in/vstram/

No responses yet