23.11.2020

Grafana and just married & PMM was born to monitor your DBs 1

Who we are

The Company > Founded in 2010 > More than 70 specialists > Specialized in the Middleware Infrastructure > The invisible part of IT > Customers in Switzerland and all over Europe

Our Offer > Consulting > Service Level Agreements (SLA) > Trainings > License Management

Grafana and Prometheus just married & PMM was born to monitor your DBs 19.11.2020 Page 2 2 23.11.2020

About me

Elisa Usai Delivery Manager & Consultant +41 78 638 09 78 elisa.usai[at]dbi-services.com Elisa Usai elisetta1984

Grafana and Prometheus just married & PMM was born to monitor your DBs 19.11.2020 Page 3 3

Agenda

Grafana and Prometheus just married & PMM was born to monitor your DBs 19.11.2020 Page 4 4 23.11.2020

Agenda

1.Introduction 2.Percona Monitoring and Management (PMM) tool 3.Monitor your DBs with PMM 4.Conclusion

Grafana and Prometheus just married & PMM was born to monitor your DBs 19.11.2020 Page 5 5

Introduction

1

> Monitor a DB 2 > Prometheus > Grafana > The benefits of a marriage 3

4

Grafana and Prometheus just married & PMM was born to monitor your DBs 19.11.2020 Page 6 6 23.11.2020

Introduction Monitor a DB Why is the monitoring so essential?

> Services Health > System Optimization > Performance Problems > Business Process Improvement > Capacity Planning

What could we monitor?

> Databases, Instances > Hosts > CPU, Memory, I/O, Network > Storage, Filesystems > Application

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 7 7

Introduction Monitor a DB

And finally what makes the difference nowadays?

> Multiple databases > Comparisons between machines, instances configuration > Features > Price

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 8 8 23.11.2020

Introduction

Once upon a time…

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 9 9

Introduction Prometheus

What is Prometheus?

> Open source tool Event monitoring Alerting

> 100% community-driven

> Apache 2 licence

> Go

> https://prometheus.io

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 10 10 23.11.2020

Introduction Prometheus push Alertmanager notify Components alerts

HTTP pull metrics Prometheus

Pushgateway Grafana ServiceJobs Exporter Exporter Short-lived jobs

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 11 11

Introduction Prometheus

Some features…

> Multi-dimensional data model > PromQL > No reliance on distributed storage > Pull model over HTTP > Service discovery or static configuration > Graphing and dashboarding support

When to use it? When not to use it?

> Recording numeric time series data (metrics) > If you need 100% accuracy (per-request billing)

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 12 12 23.11.2020

Introduction Grafana

What is Grafana?

> Open source tool Visualize data Monitoring Performance analysis Alerting

> Multiple data sources

> Dashboards and plugins

> Configurable

> https://grafana.com

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 13 13

Introduction Grafana push Alertmanager notify Components alerts

HTTP pull metrics Prometheus

PromQL data visualization

Pushgateway Grafana ServiceJobs Exporter Exporter Short-lived jobs

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 14 14 23.11.2020

Introduction The benefits of a marriage

Requirements

> Good communication > Solid roots > Common interests

Advantages

> Living in the same space > Tasks sharing > Stability

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 15 15

Introduction

PMM

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 16 16 23.11.2020

Percona Monitoring and Management (PMM) tool

1

> Percona 2 > PMM introduction > PMM server > PMM client 3 > PMM overview 4

Grafana and Prometheus just married & PMM was born to monitor your DBs 19.11.2020 Page 17 17

Percona Monitoring and Management (PMM) tool Percona The story of Percona What is Percona?

> Peter Zaitsev > Provider of open source DB solutions > Vadim Tkachenko > Multi-vendor environments > Worked at MySQL AB MySQL > Co-founded Percona (2006) MariaDB MongoDB Postgres

> No vendor lock-in

> On-premises and Cloud environments

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 18 18 23.11.2020

Percona Monitoring and Management (PMM) tool PMM introduction

What is PMM?

> Open source tool for monitoring managing MySQL, PostgreSQL and MongoDB performances

> Developed by Percona

> https://www.percona.com/doc/percona- monitoring-and-management/index.html

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 19 19

Percona Monitoring and Management (PMM) tool PMM introduction

Architecture

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 20 20 23.11.2020

Percona Monitoring and Management (PMM) tool PMM server

> PMM server as appliance via: 1. Docker image 2. Open Virtual Appliance 3. Amazon Machine Image

> Requirements (for option 1) Docker >= 1.12.6 Storage: > 1GB Memory: > 2GB

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 21 21

Percona Monitoring and Management (PMM) tool PMM client

> PMM client Agents Exporters

> https://www.percona.com/downloads/pmm/ DEB packages for Ubuntu RPM packages for CentOS Generic tarballs Source code

> Requirements Different host name Storage: > 100MB Good connection to PMM server

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 22 22 23.11.2020

Percona Monitoring and Management (PMM) tool PMM overview

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 23 23

Percona Monitoring and Management (PMM) tool PMM overview

Dashboards

> Default Dashboards

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 24 24 23.11.2020

Percona Monitoring and Management (PMM) tool PMM overview

Dashboards

> Possibility to Create custom Dashboards Import Dashboards

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 25 25

Percona Monitoring and Management (PMM) tool PMM overview

Metrics

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 26 26 23.11.2020

Percona Monitoring and Management (PMM) tool PMM overview

PMM Settings

> Metrics resolution, retention time, telemetry, check for updates, security tool

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 27 27

Percona Monitoring and Management (PMM) tool PMM overview

PMM Settings

> Diagnostic

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 28 28 23.11.2020

Percona Monitoring and Management (PMM) tool PMM overview

Alerting

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 29 29

Percona Monitoring and Management (PMM) tool PMM overview

Alerting … using Grafana Alerting feature … using External Prometheus Alertmanager > Integrated into PMM Server > More sophisticated alert rules > Simpler to set-up > Easier to manage many hosts > Configured in the Alert Tab of any dashboard > Maybe integrated into PMM in next releases! graph panel

https://grafana.com/docs/grafana/latest/alerting/al https://prometheus.io/docs/alerting/alertmanager/ erts-overview/

https://www.percona.com/blog/2017/02/02/pmm- alerting-with-grafana-working-with-templated- dashboards/

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 30 30 23.11.2020

Percona Monitoring and Management (PMM) tool PMM overview

Alerting … using Grafana Alerting feature … using External Prometheus Alertmanager > Integrated into PMM Server > More sophisticated alert rules > Simpler to set-up > Easier to manage a large number of hosts > Configured in the Alert Tab of any dashboard > Maybe integrated into PMM in next releases! graph panel

https://grafana.com/docs/grafana/latest/alerting/ru https://prometheus.io/docs/alerting/alertmanager/ les/

https://www.percona.com/blog/2017/02/02/pmm- alerting-with-grafana-working-with-templated- dashboards/

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 31 31

Percona Monitoring and Management (PMM) tool PMM overview

Prometheus Alertmanager

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 32 32 23.11.2020

Percona Monitoring and Management (PMM) tool PMM overview

User Management

> Users > Roles Admin Editor Viewer

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 33 33

Percona Monitoring and Management (PMM) tool PMM overview

Query Analytics

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 34 34 23.11.2020

Monitor your DBs with PMM

1

> MySQL/MariaDB Monitoring 2 > Galera Cluster Monitoring > Postgres Monitoring > Oracle Monitoring 3 > and much more… 4

Grafana and Prometheus just married & PMM was born to monitor your DBs 19.11.2020 Page 35 35

Percona Monitoring and Management (PMM) tool MySQL/MariaDB Monitoring

> PMM user in MySQL 8.0 default_authentication_plugin = caching_sha2_password SHA-256 authentication not supported by PMM

 PMM user: mysql_native_password!

> Adding MySQL/MariaDB service monitoring # pmm-admin add --query-source=slowlog --username=pmm --password=manager mysql-master 127.0.0.1:33001

> query-source Slow Log (slowlog) Performance Schema (perfschema)

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 36 36 23.11.2020

Percona Monitoring and Management (PMM) tool Galera Cluster Monitoring

> Adding MariaDB Galera Cluster service monitoring

First node # pmm-admin add mysql --username=pmm --password=manager --query-source=perfschema -- service-name=galera1 --host=localhost --port=3306

Second node # pmm-admin add mysql --username=pmm --password=manager --query-source=perfschema -- service-name=galera2 --host=localhost --port=3306

Third node # pmm-admin add mysql --username=pmm --password=manager --query-source=perfschema -- service-name=galera3 --host=localhost --port=3306

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 37 37

Percona Monitoring and Management (PMM) tool Postgres Monitoring

> postgres.conf shared_preload_libraries = 'pg_stat_statements' track_activity_query_size = 2048 pg_stat_statements.track = all

> PMM user and extension postgres=# CREATE USER pmm WITH SUPERUSER ENCRYPTED PASSWORD 'pwd'; postgres=# CREATE EXTENSION pg_stat_statements SCHEMA public;

> pg_hba.conf # TYPE DATABASE USER ADDRESS METHOD host all pmm 127.0.0.1/32 md5

> Adding Postgres service monitoring # pmm-admin add --username=pmm --password=manager postgres 127.0.0.1:5432

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 38 38 23.11.2020

Percona Monitoring and Management (PMM) tool Oracle Monitoring

> Download the external exporter https://github.com/freenetdigital/prometheus_oracle_exporter

> Configure and launch it # cat oracle.conf connections: - connection: pmm/"XXX"@ORCL database: ORCL instance: orcl alertlog: - file: /u01/app/oracle/diag/rdbms/orcl/orcl/trace/alert_orcl.log ignoreora: - ORA-00001 - ORA-01033 …

# ./prometheus_oracle_exporter-amd64 -configfile=/root/PMM_demo/prometheus_oracle_exporter- master/oracle.conf --web.listen-address :9161 --recovery &

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 39 39

Percona Monitoring and Management (PMM) tool Oracle Monitoring

> Add a service to collect metrics from the external exporter # pmm-admin add external --service-name="oracle" --listen-port=9161

> Add a new Oracle folder

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 40 40 23.11.2020

Percona Monitoring and Management (PMM) tool Oracle Monitoring

> Import json files to add Grafana Dashboards

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 41 41

Percona Monitoring and Management (PMM) tool Oracle Monitoring

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 42 42 23.11.2020

Percona Monitoring and Management (PMM) tool Oracle Monitoring

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 43 43

Percona Monitoring and Management (PMM) tool and much more…

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 44 44 23.11.2020

Conclusion

1

> Advantages vs Drawbacks 2

3

4

Grafana and Prometheus just married & PMM was born to monitor your DBs 19.11.2020 Page 45 45

Conclusion Advantages vs Drawbacks

No license needed. Documentation is weak.

Customizable. Server cannot be installed by packages. Centralized monitoring tool. Not for beginners.

Plenty of features.

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 46 46 23.11.2020

Conclusion

… and they lived happily ever after!

Grafana and Prometheus just married & PMM was born to monitor your DBs19.11.2020 Page 47 47

Basel Delémont Zürich

Bern Nyon Any questions?

Please do ask! We would love to boost your IT-Infrastructure How about you?

Grafana and Prometheus just married & PMM was born to monitor your DBs 19.11.2020 Page 48 48