Code Monkey home page Code Monkey logo

materialize-sql-exporter-demo's Introduction

Materialize + Prometheus SQL Exporter + Grafana

This is a demo of how to use the Prometheus SQL Exporter to export data from Materialize to Prometheus, and then use Grafana to visualize the data.

Overview

The demo consists of the following components:

  • A Materialize instance
  • A Prometheus instance
  • A Prometheus SQL Exporter instance
  • A Grafana instance

Prerequisites

Running the demo

  • Start by cloning the repository:

    git clone TODO_URL
    cd TODO_DIR
  • Copy the config.yml.example file to config.yml:

    cp config.yml.example config.yml
  • Edit the config.yml file and set your Materialize details under the connection section:

      - "postgres://YOUR_MATERIALIZE_USER:YOUR_MATERIALIZE_PASSWORD@YOUR_MATERIALIZE_HOST.materialize.cloud:6875/materialize"
  • Start the demo:

    docker-compose up -d
  • Open Grafana at http://localhost:3000 and check out the Materialize Example dashboard.

Configuration overview

The config.yml file contains the configuration for the SQL exporter. In the jobs section, there are two main sections:

  • The connections section where you can configure the SQL exporter to connect to multiple Materialize instances:
jobs:
- name: "global"
  interval: '1m'
  connections:
  - "postgres://YOUR_MATERIALIZE_USER:YOUR_MATERIALIZE_PASSWORD@YOUR_MATERIALIZE_HOST.materialize.cloud:6875/materialize"

You can change the interval at which the exporter queries Materialize by changing the interval value. The connections section contains the connection string for the Materialize instance.

  • The queries section where you can configure the SQL exporter to export metrics from Materialize:
  queries:
  - name: "replica_memory_usage"
    help: "Replica memory usage"
    labels:
      - "replica_name"
      - "cluster_id"
    values:
      - "memory_percent"
    query:  |
            SELECT
              name::text as replica_name,
              cluster_id::text as cluster_id,
              memory_percent::float as memory_percent
            FROM mz_cluster_replicas r join mz_internal.mz_cluster_replica_utilization u on r.id=u.replica_id;

The queries section contains all the queries that the SQL exporter will run to export metrics from Materialize. Each query has the following fields:

  • The name of the metric: This is the name of the metric that will be exported to Prometheus
  • The help text: This is the text that will be displayed in the Grafana UI
  • The labels to export: These are the columns that will be used as labels in the exported metric
  • The values to export: These are the columns that will be used as values in the exported metric
  • The query to run to get the data: This is the SQL query that will be run to get the data for the metric

Adding extra SQL exporter checks

To configure the SQL exporter to export additional metrics, add a new entry to the sql_exporter section of the config.yml file. For example, to export the number of rows in the orders table, add the following:

sql_exporter:
- name: "total_orders"
    help: "Total Orders"
    values:
    - "count"
    query:  |
            select count(*) from orders

Helpful links

materialize-sql-exporter-demo's People

Contributors

bobbyiliev avatar

Stargazers

Alexander avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.