How does the MOGDB database perfectly adapt to Grafana and Prometheus?

Home > Sci-Tech

How does the MOGDB database perfectly adapt to Grafana and Prometheus?

2022-01-15 06:03:05 13 ℃

Grafana is a cross-platform, open source metrics and visualization tools that can be demonstrated by docking a variety of data sources.

Prometheus is a famous open source monitoring project that monitors the specific Exporter implementation, exporter to the destination to capture monitoring data, saved in the TSDB timing database. Prometheus also supports the PROMQL query language for custom query combination.

OpenGAUSS / MOGDB database can be perfectly adapted to Grafana and Prometheus via OpenGAUSS_EXPORTER.

The following is the rendering:

The following is a deployment process in the Kirin ARM test environment, and the x86 environment needs to replace the relevant download installation package.

1PROMETHEUS deployment

Software Download address: https: //prometheus.io/download/

Download file Prometheus-2.31.1.linux-arm64.tar.gz

# mkdir / appdata / prometheus # mkdir / appdata / prometheus / etc # mkdir / appdata / prometheus / log # mkdir / appdata / prometheus / data # tar -zxvf Prometheus-2.31.1.linux-arm64.tar.gz -C / appdata / prometheus # chown -r propdheus: / appdata / prometheus # chmod -r 755 / appdata / Prometheus $ /appdata/prometheus/prometheus-2.31.1.linux-ARM64/Prometheus - -version $ vi /appdata/prometheuse/etc/prometheus.yml

The content is as follows:

# my global configglobal: scrape_interval: 15s # Set the scrape interval to every 15 seconds Default is every 1 minute.evaluation_interval:... 15s # Evaluate rules every 15 seconds The default is every 1 minute # scrape_timeout is set to the global default (10s) # Alertmanager configurationalerting: alertmanagers: -. static_configs: - targets: # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.rule_files: # - "first_rules.yml" # - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself.scrape_configs: - job_name: 'prometheus'static_configs: - targets: [' xxxx: 50090 '] # vi / usr / lib /systemd/system/prometheus.service

The content is as follows:

[Unit] Description = PrometheusAfter = network.target [Service] Type = simpleUser = prometheusExecStart = / appdata / prometheus / prometheus-2.31.1.linux-arm64 / prometheus --web.listen-address = "0.0.0.0 : 50090 "--config.file = / appdata / prometheus / etc / prometheus.yml --storage.tsdb.path = / appdata / prometheus / dataExecReload = / bin / kill -HUP $ MAINPIDRestart = on-failure [Install] WantedBy = multi-user.target to start the service:

# systemctl daemon-reload # systemctl enable prometheus # systemctl start prometheus

2node_exporter deployment

Software Download: https: //github.com/prometheus/node_exporter/releases

Download file node_exporter-1.2.2.linux-arm64.tar.gz

extracting installation package to the root user prometheus user, test environment deployment at prometheus user.

# tar -zxvf node_exporter-1.2.2.linux-arm64.tar.gz -C / appdata / prometheus / # chown -R prometheus: /appdata/prometheus/node_exporter-1.2.2.linux-arm64 $ /appdata/prometheus/node_exporter-1.2.2.linux-arm64/node_exporter --version # vi /usr/lib/systemd/system/node_exporter.service

The content is as follows:

[Unit] Description = node exporterAfter = network.target [Service] Type = simpleUser = prometheusExecStart = / appdata / prometheus / node_exporter-1.2.2.linux-arm64 / node_exporter --web.listen-address = ": 9100 "--no-collector.softnetExecReload = / bin / kill -HUP $ MAINPIDRestart = on-failure [Install] WantedBy = multi-user.target # systemctl daemon-reload # systemctl enable node_exporter # systemctl start node_exporter

prometheus profile prometheus.yml add the following contents:

- job_name: 'node_exporter'static_configs: - targets: [' 110.128.131.16:9100 ']

Download: https: //github.com/enmotech/opengauss_exporter

Download file node_exporter-1.2.2.linux-arm64.tar.gz

# unzip opengauss_exporter_0.0.9_linux_arm64.zip -d / appdata / prometheus / opengauss_exporter # chown -R prometheus: / appdata / prometheus / opengauss_exporter file storage path: / appdata / prometheus / opengauss_exporter

edit permission:

# chown prometheus: queries.yaml

Password complexity is in line with the requirements of the database, the default requires cases + special characters, no less than 8 digits.

$ gsql -Uomm postgres -rCREATE USER db_exporter WITH PASSWORD 'XXXXXXXX' MONADMIN; grant usage on schema dbe_perf to db_exporter; grant select on pg_stat_replication to db_exporter; $ gs_guc set -I all -N all -H "host postgres db_exporter 110.128.131.16/32 md5" # vi /usr/lib/systemd/system/mogdb_exporter.service

The content is as follows:

[Unit] Description = Prometheus MogDB Exporter Server [Service] User = prometheusEnvironment = "DATA_SOURCE_NAME = PostgreSQL: // db_exporter: password @ ip:? Port / postgres sslmode = disable" ExecStart = / appdata / prometheus / opengauss_exporter / opengauss_exporter --Web.Listen-address = ": 51007" --config = "/ appdata / prometheus / OpenGAUSS_EXPORTER / queries.yaml" [install] WANTEDBY = Multi-User.target

Start service:

# systemctl daemon-reload # systemctl enable mogdb_exporter # systemctl start mogdb_exporter - job_name: 'mogdb_exporter' static_configs: - targets: [ '110.128.131.16: 51007'] # Systemctl Restart Prometheus

4GRAFANA deployment

Download address: https://grafana.com/grafana/downloadload

Download File Grafana-Enterprise-8.2.4.Linux-Arm64.tar.gz

# tar -zxvf grafana-enterprise-8.2.4.linux-arm64.tar.gz -c / appdata / prometheus / # chown -r proptheus: /appdata/prometheus/grafana-8.2.4 < Code> $ vi /appdata/prometheus/grafana-8.2.4/conf/defaults.ini

For example, modify http_port = 51009, modify the built-in database 3306 port.

# vi /usr/lib/systemd/system/grafana.service

The content is as follows:

[Unit] Description = Grafana Server [Service] User = prometheusExecStart = / appdata / prometheus / grafana-8.2.4 / bin / grafana-server -homepath /appdata/prometheus/grafana-8.2.4/ -config / appdata/prometheus/grafana-8.2.4/conf/defaults.ini [install] WANTEDBY = MULTI-USER.TARGET Startup service:

# systemctl daemon-reload # systemctl enable grafana.service # systemctl start grafana.service

Peng Chong, Yun and Enk PG Technical Consultant, Net Name "Dan Dad", PG Community Certification Expert, China's first phase Postgresql Ace Partner, has been engaged in the software R & D based on PostgreSQL database, is good at PL / PGSQL business migration and optimization,Oracle to PostgreSQL migration upgrade, heterogeneous database integration; as the autograft author of Mo Tianhe POSTGRESQL practice column, passionate about PostgreSQL practical technology sharing, actively promoting PostgreSQL in his position, dedication to PG community.