监控指南

监控 Write-behind 引擎和数据处理作业

Write-behind 累积作统计信息,您可以:

  • 观察和分析以发现各种类型的问题。
  • 用于优化目的。

控制台指标

Write-behind 可以在控制台中使用redis-di status命令。该命令提供有关当前 Write-behind 引擎状态、目标数据库配置和按流细分的处理统计信息的信息。此工具旨在供 Operator 用于获取系统的当前快照以及监控正在进行的数据处理(在实时模式下使用时)。

Prometheus 集成

Write-behind 允许收集其指标并将其导出到 Prometheus,并在 Grafana 中可视化它们。Operator 可以使用redis-di monitor命令。该图描述了此流程和涉及的组件:

注意:上面的主机名和端口只是示例,可以根据需要进行更改。

测试 Write-behind 指标导出器

使用以下命令启动 Write-behind 指标导出器:

redis-di monitor

Note: The default port for the exporter is 9121. If you need to change it, use the --exporter-port option. The default metrics collection interval is 5 seconds. If you need to change it, use the --collect-interval option.

Then navigate to http://localhost:9121/ to see the exported metrics. You should be able to see the following metric:

rdi_engine_state{state="RUNNING",sync_mode="UNKNOWN"} 1.0

Note: The actual value of the metric above can be 0 if you haven't started Write-behind engine yet (in which case, the state label should indicate that as well). You must have the Write-behind database created and configured before observing any metrics. If you are not seeing it or getting an error value instead, this indicates that the Write-behind database is not properly configured.

Configure Prometheus

Next, configure the Prometheus scraper. Edit the prometheus.yml file to add the following scraper config:

scrape_configs:
  # scrape Write-behind metrics exporter
  - job_name: rdi-exporter
    static_configs:
      - targets: ["redis-exporter:9121"]

Notes:

  • Make sure the targets value above points to the host and port you configured to run the Write-behind metrics exporter.
  • The scrape_interval setting in Prometheus should be the same or higher than the collect_interval setting for the exporter. For example, if the collect_interval is set to 5 seconds, the scrape_interval should also be set to 5 seconds or more. If the scrape_interval is set to less than the collect_interval, Prometheus will scrape the exporter before it has a chance to collect and refresh metrics, and you will see duplicated values in Prometheus.

Test the Prometheus scraper

After the scraper config is added to the Prometheus configuration, you should now be able to navigate to http://<HOSTNAME>:9090/graph (replace <HOSTNAME> with a valid Prometheus hostname or IP address).

Explore Write-behind metrics using the expression browser.

In the expression box, type in a metric name (for example, rdi_engine_state) and select Enter or the Execute button to see the following result:

rdi_engine_state{instance="redis-exporter:9121", job="rdi-exporter", status="RUNNING", sync_mode="UNKNOWN"} 1

Note: You may see more than just one Write-behind metric if Write-behind engine has already processed some data. If you do not see any metrics, check your scraper job configuration in Prometheus.

Use Grafana to analyze metrics

Optionally, you may deploy the sample Grafana dashboard to monitor the status of Write-behind engine and its individual jobs. Follow these steps to import the dashboard:

  1. Download the dashboard file to your local machine.

  2. Log into Grafana and navigate to the list of dashboards, then choose New > Import:

  1. On the next screen, select Upload JSON file and upload the file you downloaded in step 1. Make sure you select the data source that is connected to the Write-behind metrics exporter:
  1. Select Import and make sure you choose the jobs to monitor from the drop-down list (this will be empty if you don't have any jobs running yet):

Write-behind metrics

This list shows exported Write-behind metrics along with their descriptions:

Metric Name Labels Values Description
rdi_engine_state {status=RUNNING | STOPPED, sync_mode=SNAPSHOT | STREAMING | UNKNOWN} 0, 1 Status of Write-behind engine. 0 - Write-behind engine is stopped, 1 - Write-behind engine is running. Sync mode label indicates the last reported ingest synchronization mode.
rdi_incoming_entries {data_source=<stream name>, operation=pending | inserted | updated | deleted | filtered | rejected} <count of records> Counters, indicating the number of operations performed for each stream.
rdi_stream_event_latency_ms {data_source=<stream name>} 0 - ∞ Latency calculated for each stream. Indicates the time in milliseconds the first available record has spent in the stream waiting to be processed by Write-behind engine. If no records pending it will always return zero.