Customize Monitoring

Configure Monitoring using SQL

Note

Using SingleStore Toolbox to configure cluster monitoring is the easier, preferred, and default method.

Enable the Exporter Process

The memsql-exporter process (or simply the exporter) collects data about a running cluster. The user that starts the exporter (other than the SingleStore root user) must have the following permissions at a minimum:

GRANT CLUSTER on *.* to <user>
GRANT SHOW METADATA on *.* to <user>
GRANT SELECT on *.* to <user>
GRANT PROCESS on *.* to <user>

Start the Exporter Process

Perform the following steps on the Source cluster Master Aggregator.

Note that the exporter process is restarted when the exporter_port variable is set to any non-zero value, including the current value. The exporter_port variable can be set by running SET GLOBAL exporter_port = <port>;.

HTTP Connections

You may start the exporter in the SingleStore engine by passing a user, port, and password to the exporter. The following example shows the exporter being started with the SingleStoreroot user:

SET GLOBAL exporter_user = root;
SET GLOBAL exporter_password = '<secure-password>';
SET GLOBAL exporter_port= 9104;
HTTPS Connections
  1. Copy the server certificate and key to the Master Aggregator host of the Source cluster. This certificate will be used by the exporter process and must be readable by the user under which the nodes are running on the host (typically the memsql user).

  2. Use the following SQL statements to start the exporter in the SingleStore engine.

    SET GLOBAL exporter_user = root;
    SET GLOBAL exporter_password = '<secure-password>';
    SET GLOBAL exporter_use_https= true;
    SET GLOBAL exporter_ssl_cert = '/path/to/server-cert.pem';
    SET GLOBAL exporter_ssl_key = '/path/to/server-key.pem';
    SET GLOBAL exporter_ssl_key_passphrase= '<passphrase>';

    Note: The exporter_ssl_key_passphrase variable should only be included if the server key has a passphrase.

How to Stop the Exporter Process

You may stop the exporter at any time by running the following command on the Source cluster Master Aggregator.

Use an engine variable to stop the exporter process by setting the port to 0.

SET GLOBAL exporter_port = 0;

Configure the metrics Database

The metrics database can either reside in the Source cluster, in a dedicated Metrics cluster, or in a remote SingleStore cluster that the Metrics cluster can access.

Note that the user that creates the metrics database may differ from the one that started the exporter. This user must be able to create tables, databases, and pipelines. At a minimum, the following permissions are required:

metrics Database DDL

You may run the following SQL scripts to configure the database.

Please note the following:

  • The database that is created to store monitoring data is named metrics by default. You must edit these SQL statements manually to change the database name.

  • The database user is root by default. When creating the metrics database with a database user other than root, the SUPER privilege must be granted to this user. For example, for a dbmon user:

    GRANT SUPER ON *.* TO 'dbmon'@'%';

  • These commands must be run on the Master Aggregator of the Metrics cluster.

Create the metrics database and associated tables by copying, pasting, and executing each set of SQL statements below.

You may also download the latest metrics database DDL SQL file from SingleStore.

Pipelines DDL

Run the following in a SQL client.

Note: You must edit exporter-host and port in the following SQL statements to align with where your exporter process resides.

  • The exporter-host is typically the host of your Source cluster’s Master Aggregator that’s running the exporter, and must include http://.

  • The default port for the endpoint is 9104.

  • The IP address provided in the exporter-host argument must be resolvable by all hosts in the cluster. If the cluster you are monitoring has hosts that contain leaf nodes (as is common in a multi-host vs. single-host deployment), do not use localhost. Instead, provide the explicit IP address or hostname that the other hosts in the cluster can resolve.

HTTP Connections
  1. Start the metrics pipeline.

    CREATE OR REPLACE PIPELINE metrics.metrics AS
    LOAD DATA prometheus_exporter
    "http://<exporter-host>:<exporter-port>/cluster-metrics"
    CONFIG '{"is_memsql_internal":true, "high_cardinality_metrics":false,
    "monitoring_version":"<SingleStore version of the 'metrics' cluster>"}'
    batch_interval 15000
    INTO PROCEDURE `load_metrics` FORMAT JSON;
    START PIPELINE IF NOT RUNNING metrics.metrics;
  2. Start the blobs pipeline.

    CREATE OR REPLACE PIPELINE metrics.blobs AS
    LOAD DATA prometheus_exporter
    "http://<exporter-host>:<exporter-port>/samples"
    CONFIG '{"is_memsql_internal":true,
    "download_type":"samples", "sample_queries":true,
    "monitoring_version":"<SingleStore version of the metrics cluster>"}'
    batch_interval 15000
    INTO PROCEDURE `load_blobs` FORMAT JSON;
    START PIPELINE IF NOT RUNNING metrics.blobs;
HTTPS Connections
  1. Copy the CA certificate to the same file path on each host of the Metrics cluster.

    Alternatively, a directory containing multiple CA certificates can be provided, and this path must be the same on all hosts. This directory will be used by the monitoring pipelines and must be readable by the user under which the nodes are running on the host (typically the memsql user).

  2. Start the metrics pipeline.

    CREATE OR REPLACE PIPELINE metrics.metrics AS
    LOAD DATA prometheus_exporter
    "https://<exporter-host>:<exporter-port>/cluster-metrics"
    CONFIG '{"is_memsql_internal":true, "high_cardinality_metrics":false,
    "monitoring_version":"<SingleStore version of the 'metrics' cluster>",
    "ssl_ca":"path to ca cert" OR "ssl_capath":"path to ca dir"}'
    batch_interval 15000
    INTO PROCEDURE `load_metrics` FORMAT JSON;
    START PIPELINE IF NOT RUNNING metrics.metrics;
  3. Start the blobs pipeline.

    CREATE OR REPLACE PIPELINE metrics.blobs AS
    LOAD DATA prometheus_exporter
    "https://<exporter-host>:<exporter-port>/samples"
    CONFIG '{"is_memsql_internal":true,
    "download_type":"samples", "sample_queries":true,
    "monitoring_version":"<SingleStore version of the metrics cluster>",
    "ssl_ca":"path to ca cert" OR "ssl_capath":"path to ca dir"}'
    batch_interval 15000
    INTO PROCEDURE `load_blobs` FORMAT JSON;
    START PIPELINE IF NOT RUNNING metrics.blobs;

How to Stop the Monitoring Process

You may stop the monitoring process at any time by manually stopping the pipelines created earlier.

STOP PIPELINE metrics;
STOP PIPELINE blobs;

Last modified: March 1, 2024

Was this article helpful?