Simple Monitoring for Java Applications and Database

通常,Java应用程序使用数据库作为存储。有了一个已经运行的应用程序,它不一定那么容易支持和维护。我们将回顾一些有MySQL支持的Java应用程序的情况,以及如何使用。您将在一个系统中看到有关Java、系统和数据库的信息,并且能够分析它,
我们将看到最新版本的PelCONA监视和管理系统(PMM),并将其与JMX导出器相结合,以从Java度量获取数据。所有这些都将被收集在普罗米修斯。我们将查看仪表盘,并了解如何创建自己的仪表盘。

展开查看详情

1.Simple Monitoring for Java Applications and Database Roma Novikov Percona

2.Introduction Click to add text

3.About Myself Roma Novikov ● Percona - Director of Platform, Engineering (2+ years) ● Since 2001: Web developer -> Lead/Architect -> Manager -> CTO Interests: ● web, highload, monitoring, and observability 3

4.The Goal of This Presentation Show the simple way to set up monitoring for Java application with database in one monitoring system and without changing the application Focused for: ● Ops - to show how to get a general view of the application ● Devs - get to know what you are shipping in an easy way 4

5.Presentation Matters ● Visualization is a key - no language needed ● Get everyone on the same page ● Give managers meaningful information 5

6.Monitoring / Metrics Click to add text

7.What to Use? ● “Common tools” ● top ● ps aux ● SHOW PROCESSLIST ● Why I need something new? ● What about data from “yesterday”? ● What's going on now with another part of the system? How is it affected? 7

8.What to Use? ● Saas/Paas + Vendor provided + DIY open source ● Challenges selecting the tools ○ Price ○ Support ○ Different environment coverage! ■ (Remember (hybrid) Clouds!) 8

9.What to Use? Percona’s choice: Prometheus and Grafana ● Prometheus ○ Simple but powerful architecture and data model ○ Exposition format ○ Targets ● Grafana ○ Data sources (30+) ○ Panel Types (50+) ○ Dashboards (X+) 9

10. PMM Percona Monitoring and Management

11.Why Did We Create PMM? ● A single tool to cover all supported databases ● Makes life easy with Prometheus and Grafana ● A common tool for internal use 1 1

12.Architecture Main Components: ● Prometheus ● Grafana ● Percona dashboards ● Consul ● Query Analytics ● CLI tool ● Prometheus exporters 1 2

13.Distribution ● Client ○ Linux package ○ Binary ● Server ○ Docker image ○ AWS Marketplace ○ Virtual appliances - OVF 1 3

14.How to Extend? ● External services ● Write PR and add new technology 1 4

15.Setting up Monitoring Click to add text

16.Introduction ● What will we monitor? ○ Java Application as .jar + Database (MySQL) in docker ● How? ○ Pmm = OS + Database monitoring ○ External services monitoring - JMX_exporter to add inside PMM ● Result ○ One app / Datasource (PMM / Prometheus) with data about OS, DB, JVM ○ Simple dashboard to see all at once 1 6

17.Big Picture JAVA DB PMM Server OVF PMM Client package jmx_exporter 1 7

18.PMM Server 1. Setup and run PMM Server - https://www.percona.com/downloads/pmm/ 1 8

19.Client - Description ● Java application as .jar file + DB (MySQL) in docker ● Used Vagrant for simplification 1 9

20.Client - Installation ● Get jmx_exporter for Prometheus ○ Jmx_exporter: https://github.com/prometheus/jmx_exporter ● Download https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_p rometheus_javaagent/0.11.0/jmx_prometheus_javaagent-0. 11.0.jar ● Start Java APP and Java agent with JMX exporter ○ Create config file config.yaml ■ Empty file = track everything 2 0

21.Client - Run ● Run: # java -javaagent:./jmx_prometheus_javaagent-0.11.0.jar=8181: config.yaml -jar myapp.jar ● 8181 - port for the exporter 2 1

22.Client - Verify Exporter ● Open http://192.168.0.105:8181/metrics ● Exporter - OK 2 2

23.Client - Install pmm-client ● Configuring Percona Repositories with percona-release https://www.percona.com/doc/percona-repo-config/percona-release.html ● install pmm-client sudo apt-get install pmm-client ● Configure Client sudo pmm-admin config --server=192.168.0.104 --server-insecure-ssl --server-password=admin --server-user=admin OK, PMM server is alive. PMM Server | 192.168.0.104 (insecure SSL, password-protected) Client Name | vagrant Client Address | 192.168.0.105 2 3

24.Client - Configure Monitoring ● Add MySQL monitoring sudo pmm-admin add mysql [linux:metrics] OK, now monitoring this system. [mysql:metrics] OK, now monitoring MySQL metrics using DSN root:***@tcp(localhost:3306) [mysql:queries] OK, now monitoring MySQL queries from perfschema using DSN root:***@tcp(localhost:3306) ● Add External service for monitoring sudo pmm-admin add external:service JMX --service-port=8181 External service added. 2 4

25.Client - Verify Installation ● Verification command sudo pmm-admin list pmm-admin 1.17.1 PMM Server | 192.168.0.104 (insecure SSL, password-protected) Client Name | vagrant Client Address | 192.168.0.105 Service Manager | linux-systemd ... 2 5

26.Client - Verify Installation ... -------------- -------- ----------- -------- ----------------------------- --------------------------------------------- SERVICE TYPE NAME LOCAL PORT RUNNING DATA SOURCE OPTIONS -------------- -------- ----------- -------- ----------------------------- --------------------------------------------- mysql:queries vagrant - YES root:***@tcp(localhost:3306) query_source=perfschema, query_examples=true linux:metrics vagrant 42000 YES - mysql:metrics vagrant 42002 YES root:***@tcp(localhost:3306) .. 2 6

27.Client - Verify Installation … Job name Scrape interval Scrape timeout Metrics path Scheme Target Labels Health JMX 1m0s 10s /metrics http 192.168.0.105:8181 instance="vagrant" UP 2 7

28.Visualisation Click to add text

29.MySQL in Grafana 2 9