docs/contrib/prometheus-grafana.md
OpenIM offers various flexible deployment options to suit different environments and requirements. Here is a simplified and optimized description of these deployment options:
nohup method. This is a basic deployment method suitable for development and testing environments. For details, refer to the Regular Source Code Deployment Guide.system method, more suitable for production environments. This method provides higher stability and reliability. For details, refer to the Production-Level Deployment Guide.Next, we will introduce the specific steps, monitoring, and management backend configuration for each of these deployment methods, as well as usage tips to help you choose the most suitable deployment option according to your needs.
OpenIM deploys openim-server and openim-chat from source code, while other components are deployed via Docker.
For Docker deployment, you can deploy all components with a single command using the openimsdk/openim-docker repository. The deployment configuration can be found in the environment.sh document, which provides information on how to learn and familiarize yourself with various environment variables.
For Prometheus, it is not enabled by default. To enable it, set the environment variable before executing make init:
export PROMETHEUS_ENABLE=true # Default is false
Then, execute:
make init
docker compose up -d
To configure Prometheus data sources in Grafana, follow these steps:
Log in to Grafana: First, open your web browser and access the Grafana URL. If you haven't changed the port, the address is typically http://localhost:13000.
Log in with default credentials: Grafana's default username and password are both admin. You will be prompted to change the password on your first login.
Access Data Sources Settings:
Add a New Data Source:
Click Add New connection to add more data sources, such as Loki (responsible for log storage and query processing).
Configure the Prometheus Data Source:
http://172.28.0.1:19090, with the address matching the DOCKER_BRIDGE_GATEWAY variable address). OpenIM and the components are linked via a gateway. The default port used by OpenIM is 19090.Save and Test:
Importing Dashboards in Grafana
Importing Grafana Dashboards is a straightforward process and is applicable to OpenIM Server application services and Node Exporter. Here are detailed steps and necessary considerations:
Key Metrics Overview and Deployment Steps
To monitor OpenIM in Grafana, you need to focus on three categories of key metrics, each with its specific deployment and configuration steps:
OpenIM Metrics (prometheus-dashboard.yaml):
config/prometheus-dashboard.yaml.export PROMETHEUS_ENABLE=true.Node Exporter:
quay.io/prometheus/node-exporter for effective node monitoring.Middleware Metrics: Different middlewares require unique steps and configurations for monitoring:
Importing Steps:
Access the Dashboard Import Interface:
+ icon on the left menu or in the top right corner of Grafana, then select "Create."Perform Dashboard Import:
Configure the Dashboard:
Save and View the Dashboard:
Graph Examples:
This guide provides the steps to run OpenIM using Docker. OpenIM is an open-source instant messaging solution that can be quickly deployed using Docker. For more information, please refer to the OpenIM Docker GitHub.
First, clone the OpenIM Docker repository:
git clone https://github.com/openimsdk/openim-docker.git
Navigate to the repository directory and check the README file for more information and configuration options.
In the repository directory, run the following command to start the service:
docker-compose up -d
This will download the required Docker images and start the OpenIM service.
admin1:admin1).Running Effect Image:
admin:admin).README file for advanced configuration and management.Refer to openimsdk/helm-charts.
When deploying and monitoring OpenIM in a Kubernetes environment, you will focus on three main metrics: middleware, custom OpenIM metrics, and Node Exporter. Here are detailed steps and guidelines:
Middleware monitoring is crucial to ensure the overall system's stability. Typically, this includes monitoring the following components:
For Kubernetes environments, you can use the corresponding Prometheus Exporters to collect monitoring data for these middleware components.
Custom OpenIM metrics provide essential information about the OpenIM application itself, such as user activity, message traffic, system performance, and more. To monitor these metrics in Kubernetes:
Node Exporter is used to collect hardware and operating system-level metrics for Kubernetes nodes, such as CPU, memory, disk usage, and more. To integrate Node Exporter in Kubernetes:
make initAlertManager, a component of the Prometheus monitoring system, handles alerts sent by client applications such as the Prometheus server. It takes care of deduplicating, grouping, and routing them to the correct receiver. This document outlines how to set up and configure AlertManager using environment variables and the make init command. We will focus on configuring key fields like the sender's email, SMTP settings, and SMTP authentication password.
Before initializing AlertManager, you need to set environment variables. These variables are used to configure the AlertManager settings without altering the code. Use the export command in your terminal. Here are some key variables you might set:
export ALERTMANAGER_RESOLVE_TIMEOUT='5m'export ALERTMANAGER_SMTP_FROM='[email protected]'export ALERTMANAGER_SMTP_SMARTHOST='smtp.example.com:465'export ALERTMANAGER_SMTP_AUTH_USERNAME='[email protected]'export ALERTMANAGER_SMTP_AUTH_PASSWORD='your_password'export ALERTMANAGER_SMTP_REQUIRE_TLS='false'After setting the necessary environment variables, you can initialize AlertManager by running the make init command. This command typically runs a script that prepares AlertManager with the provided configuration.
ALERTMANAGER_SMTP_FROM)This variable sets the email address that will appear as the sender in the notifications sent by AlertManager.
ALERTMANAGER_SMTP_SMARTHOST): Specifies the address and port of the SMTP server used for sending emails.ALERTMANAGER_SMTP_AUTH_USERNAME): The username for authenticating with the SMTP server.ALERTMANAGER_SMTP_AUTH_PASSWORD): The password for SMTP server authentication. It's crucial to keep this value secure.The SMTP authentication password can be set using the ALERTMANAGER_SMTP_AUTH_PASSWORD environment variable. It's recommended to use a secure method to set this variable to avoid exposing sensitive information. For instance, you might read the password from a secure file or a secret management tool.
For specific configurations related to common email servers, you may refer to their respective documentation:
Setting up and configuring AlertManager with environment variables provides a flexible and secure way to manage alert settings. By following the above steps, you can easily configure AlertManager for your monitoring needs. Always ensure to secure sensitive information, especially when dealing with SMTP authentication credentials.