SlideShare a Scribd company logo
Monitoring PostgreSQL using Time-Series
systems like Graphite and/or Grafana with
OpenCollector
Jan Wieck - OpenSCG
Overview
‱ What is Monitoring?
‱ Graphite & Carbon
‱ Grafana
‱ Why use Carbon?
‱ Why use Graphite AND Grafana?
‱ PostgreSQL Metric Data
‱ OpenCollector
‱ osinfofdw
What is Monitoring?
‱ Capture Time-Series data
‱ Metric-Name, Value, Timestamp
‱ Visualize Time-Series data
‱ Define alerts base on Time-Series data
‱ Statistical analysis of Time-Series data
‱ Getting an alert when your primary DB server is
down is covered by the above!
Graphite & Carbon
‱ Carbon is a server for collecting Time-Series
data
‱ Simple line based protocol on port 2003
‱ Python-pickle protocol on port 2004
‱ Graphite is a WEB based GUI on top of Carbon
‱ Some Dashboard functionality
Example Graphite screen
Grafana
‱ Grafana is more Dashboard focused
‱ Grafana can use many Time-Series data sources
‱ Graphite
‱ Elasticsearch
‱ CloudWatch
‱ InfluxDB
‱ OpenTSDB
‱ KairosDB
‱ Prometheus
Example Grafana dashboard
Why use Carbon?
Carbon provides an extremely simple protocol to send
Time-Series data
#!/bin/sh
CHOST=”graphite.host.name”
CPORT=”2003”
METRIC=”test.PI”
VALUE=”3.1415”
echo ”$METRIC $VALUE ‘date +%s‘” | nc $CHOST $CPORT
Why use Carbon?
Why use Carbon?
Not a very useful metric, but consider capturing the
runtime of a shell script based cron job.
Carbon also provides a Python-pickle based protocol
on port 2004 that can be used to send hundreds of
metric points condensed in one send(1).
Why use Graphite AND Grafana?
‱ Grafana is more Dashboard focused
‱ Templating makes it easy to define one
Dashboard and use it for many hosts/databases
‱ Getting to a Dashboard is easier
‱ Can define Alerts
‱ Looks cool
‱ Graphite is better at ad-hoc graphing
‱ The metric tree is easier to navigate than clicking
through Grafana’s pull down system
However 

This isn’t a talk advertising Graphite or Grafana.
This is a talk about capturing monitoring data from
PostgreSQL and delivering it into a Time-Series data
system. Carbon/Graphite and Grafana are example
destinations.
PostgreSQL Metric Data
PostreSQL produces quite a number of data points.
‱ On the table level
‱ about 30 metric points
‱ On the index level
‱ about 6 metric points
‱ On the database level
‱ about 20 metric points
PostgreSQL Metric Data
Those per table/index numbers are not of concern
when you look at your typical benchmark database.
But what about a database with 1,800 tables and
13,000 indexes?
Now we are talking about 132,000 metric points every
time interval! Captured every minute that is 7.9M per
hour, 190M per day, 17.1B per quarter. Don’t do that
with snapshots captured inside the DB.
PostgreSQL Metric Data
That isn’t as exotic as it looks at first glance
PostgreSQL system views like pg_stat_all_user_tables
will report every single metric point even if a table or
index hasn’t been used for the past 12 months.
How many dead tables (schemas) does your
database have?
A generic monitoring system can’t tell them apart.
PostgreSQL Metric Data
But that isn’t all. Many metrics are presented in what
is a continuous counter, but the useful value is actually
their increase per second.
Examples:
‱ Tuples inserted, updated, deleted, fetched
‱ Index/Sequential scans
This is the same as for OS statistics like:
‱ Network operations
‱ Disk operations
PostgreSQL Metric Data
While that is efficient inside of the PostgreSQL server
for collecting the data, it is rather inconvenient when
browsing it in a system like Graphite or Grafana.
Sure, they can apply a function like “persecond()” and
it is only 20 mouse clicks away 

OpenCollector
‱ OpenCollector is a PostgreSQL monitoring
daemon sponsored by OpenSCG
‱ It is designed to address the aforementioned
problems
‱ JSON configuration files define all the operation
‱ Target Carbon server
‱ Source Database(s)
‱ Queries to run and what metrics they return
‱ Sparse metric reporting
OpenCollector
An example from the sample configs:
”name”: ”global_stats”,
”prefix”: ”database:{datname}.global_stats”,
”query”: [
”SELECT ”,
” datname, numbackends::float8, ”,
” xact_commit::float8, xact_rollback::float8, ”,
” blks_read::float8, blks_hit::float8, ”,
” pg_catalog.pg_database_size(datid)::float8, ”,
” pg_xlog_location_diff(pg_current_xlog_insert_location(),
”FROM pg_catalog.pg_stat_database ”,
”WHERE datname = current_database() ”
],
”result”: [
{ ”name”: ”datname”, ”type”: ”internal” },
{ ”name”: ”numbackends”, ”type”: ”value” },
{ ”name”: ”xact_commit”, ”type”: ”counter” },
...
]
OpenCollector
‱ Since the queries are in config files, you can
customize them
‱ Additional WHERE clauses
‱ Change from pg_stat_all_ to pg_stat_user_
‱ Add your own, application specific queries
‱ OpenCollector is modular and allows to add
other things
‱ OpenCollector is open source
osinfofdw
‱ osinfofdw is another open source project
sponsored by OpenSCG
‱ A MultiCorn based FDW around Python-psutil
‱ Access OS level statistics via SELECT
‱ CPU usage
‱ Memory usage
‱ Disk IO
‱ Network IO
‱ Filesystem information
Links
Links:
‱ https://bitbucket.org/openscg/opencollector
‱ https://bitbucket.org/openscg/osinfofdw
Questions?

More Related Content

PDF
Spark Summit EU talk by Miha Pelko and Til Piffl
PDF
Temporal Operators For Spark Streaming And Its Application For Office365 Serv...
PDF
Spark Summit EU talk by Zoltan Zvara
PDF
Spark Summit EU talk by Elena Lazovik
PDF
Real-time Machine Learning Analytics Using Structured Streaming and Kinesis F...
PDF
Deep Dive Into Catalyst: Apache Spark 2.0’s Optimizer
PDF
Arbitrary Stateful Aggregations using Structured Streaming in Apache Spark
PDF
Building a Streaming Microservice Architecture: with Apache Spark Structured ...
Spark Summit EU talk by Miha Pelko and Til Piffl
Temporal Operators For Spark Streaming And Its Application For Office365 Serv...
Spark Summit EU talk by Zoltan Zvara
Spark Summit EU talk by Elena Lazovik
Real-time Machine Learning Analytics Using Structured Streaming and Kinesis F...
Deep Dive Into Catalyst: Apache Spark 2.0’s Optimizer
Arbitrary Stateful Aggregations using Structured Streaming in Apache Spark
Building a Streaming Microservice Architecture: with Apache Spark Structured ...

What's hot (20)

PPTX
Chris Hillman – Beyond Mapreduce Scientific Data Processing in Real-time
PPTX
Dato vs GraphX
PDF
Realtime Risk Management Using Kafka, Python, and Spark Streaming by Nick Evans
PDF
Airstream: Spark Streaming At Airbnb
PDF
Unified Framework for Real Time, Near Real Time and Offline Analysis of Video...
PDF
Flink Forward Berlin 2017: Pramod Bhatotia, Do Le Quoc - StreamApprox: Approx...
PPTX
Case study- Real-time OLAP Cubes
PDF
Introduction to Real-time data processing
PDF
Spark Summit EU talk by Nick Pentreath
PDF
Conquering the Lambda architecture in LinkedIn metrics platform with Apache C...
PDF
Albert Bifet – Apache Samoa: Mining Big Data Streams with Apache Flink
PPTX
Presto Talk @ Hadoop Summit'15
PDF
ggplot2.SparkR: Rebooting ggplot2 for Scalable Big Data Visualization by Jong...
PDF
Understanding Query Plans and Spark UIs
PDF
Graph computation
PPTX
Apache Flink - Hadoop MapReduce Compatibility
PDF
Spark Summit EU talk by Sol Ackerman and Franklyn D'souza
PDF
Artmosphere Demo
PDF
Time-evolving Graph Processing on Commodity Clusters: Spark Summit East talk ...
PPTX
Apache Flink: API, runtime, and project roadmap
Chris Hillman – Beyond Mapreduce Scientific Data Processing in Real-time
Dato vs GraphX
Realtime Risk Management Using Kafka, Python, and Spark Streaming by Nick Evans
Airstream: Spark Streaming At Airbnb
Unified Framework for Real Time, Near Real Time and Offline Analysis of Video...
Flink Forward Berlin 2017: Pramod Bhatotia, Do Le Quoc - StreamApprox: Approx...
Case study- Real-time OLAP Cubes
Introduction to Real-time data processing
Spark Summit EU talk by Nick Pentreath
Conquering the Lambda architecture in LinkedIn metrics platform with Apache C...
Albert Bifet – Apache Samoa: Mining Big Data Streams with Apache Flink
Presto Talk @ Hadoop Summit'15
ggplot2.SparkR: Rebooting ggplot2 for Scalable Big Data Visualization by Jong...
Understanding Query Plans and Spark UIs
Graph computation
Apache Flink - Hadoop MapReduce Compatibility
Spark Summit EU talk by Sol Ackerman and Franklyn D'souza
Artmosphere Demo
Time-evolving Graph Processing on Commodity Clusters: Spark Summit East talk ...
Apache Flink: API, runtime, and project roadmap
Ad

Viewers also liked (8)

PDF
Time Series Database and Tick Stack
PDF
Database Health Check
PDF
Oracle Health Check
ODP
Shootout at the PAAS Corral
PDF
Case Studies on PostgreSQL
PDF
Really Big Elephants: PostgreSQL DW
PDF
Beautiful Monitoring With Grafana and InfluxDB
PDF
Linux Performance Tools
Time Series Database and Tick Stack
Database Health Check
Oracle Health Check
Shootout at the PAAS Corral
Case Studies on PostgreSQL
Really Big Elephants: PostgreSQL DW
Beautiful Monitoring With Grafana and InfluxDB
Linux Performance Tools
Ad

Similar to Monitoring pg with_graphite_grafana (20)

PDF
Apache CarbonData+Spark to realize data convergence and Unified high performa...
PDF
IoT databases - review and challenges - IoT, Hardware & Robotics meetup - onl...
PDF
Overview of data analytics service: Treasure Data Service
PDF
Data Analytics Service Company and Its Ruby Usage
PDF
Optimizing Presto Connector on Cloud Storage
PDF
DataEngConf: Parquet at Datadog: Fast, Efficient, Portable Storage for Big Data
PPTX
Building Scalable Aggregation Systems
PPT
Java Developers, make the database work for you (NLJUG JFall 2010)
PDF
ClickHouse Paris Meetup. Pragma Analytics Software Suite w/ClickHouse, by Mat...
PDF
Mastering Query Optimization Techniques for Modern Data Engineers
PPT
ORACLE 12C-New-Features
PDF
PostgreSQL 9.4 and Beyond @ FOSSASIA 2015 Singapore
PPTX
Intro to Apache Apex - Next Gen Platform for Ingest and Transform
PPTX
Multi dimension aggregations using spark and dataframes
PDF
Big data should be simple
PDF
From Pipelines to Refineries: Scaling Big Data Applications
PDF
Real World Storage in Treasure Data
PDF
Making sense of your data jug
PDF
Agile Oracle to PostgreSQL migrations (PGConf.EU 2013)
PDF
Nebula Graph nMeetup in Shanghai - Meet with Graph Technology Enthusiasts
Apache CarbonData+Spark to realize data convergence and Unified high performa...
IoT databases - review and challenges - IoT, Hardware & Robotics meetup - onl...
Overview of data analytics service: Treasure Data Service
Data Analytics Service Company and Its Ruby Usage
Optimizing Presto Connector on Cloud Storage
DataEngConf: Parquet at Datadog: Fast, Efficient, Portable Storage for Big Data
Building Scalable Aggregation Systems
Java Developers, make the database work for you (NLJUG JFall 2010)
ClickHouse Paris Meetup. Pragma Analytics Software Suite w/ClickHouse, by Mat...
Mastering Query Optimization Techniques for Modern Data Engineers
ORACLE 12C-New-Features
PostgreSQL 9.4 and Beyond @ FOSSASIA 2015 Singapore
Intro to Apache Apex - Next Gen Platform for Ingest and Transform
Multi dimension aggregations using spark and dataframes
Big data should be simple
From Pipelines to Refineries: Scaling Big Data Applications
Real World Storage in Treasure Data
Making sense of your data jug
Agile Oracle to PostgreSQL migrations (PGConf.EU 2013)
Nebula Graph nMeetup in Shanghai - Meet with Graph Technology Enthusiasts

Recently uploaded (20)

PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
 
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
top salesforce developer skills in 2025.pdf
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
System and Network Administration Chapter 2
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Nekopoi APK 2025 free lastest update
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
medical staffing services at VALiNTRY
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
AI in Product Development-omnex systems
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
 
Softaken Excel to vCard Converter Software.pdf
CHAPTER 2 - PM Management and IT Context
Odoo Companies in India – Driving Business Transformation.pdf
top salesforce developer skills in 2025.pdf
How Creative Agencies Leverage Project Management Software.pdf
System and Network Administration Chapter 2
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Nekopoi APK 2025 free lastest update
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Reimagine Home Health with the Power of Agentic AI​
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PTS Company Brochure 2025 (1).pdf.......
VVF-Customer-Presentation2025-Ver1.9.pptx
medical staffing services at VALiNTRY
2025 Textile ERP Trends: SAP, Odoo & Oracle
Adobe Illustrator 28.6 Crack My Vision of Vector Design
AI in Product Development-omnex systems
wealthsignaloriginal-com-DS-text-... (1).pdf

Monitoring pg with_graphite_grafana

  • 1. Monitoring PostgreSQL using Time-Series systems like Graphite and/or Grafana with OpenCollector Jan Wieck - OpenSCG
  • 2. Overview ‱ What is Monitoring? ‱ Graphite & Carbon ‱ Grafana ‱ Why use Carbon? ‱ Why use Graphite AND Grafana? ‱ PostgreSQL Metric Data ‱ OpenCollector ‱ osinfofdw
  • 3. What is Monitoring? ‱ Capture Time-Series data ‱ Metric-Name, Value, Timestamp ‱ Visualize Time-Series data ‱ Define alerts base on Time-Series data ‱ Statistical analysis of Time-Series data ‱ Getting an alert when your primary DB server is down is covered by the above!
  • 4. Graphite & Carbon ‱ Carbon is a server for collecting Time-Series data ‱ Simple line based protocol on port 2003 ‱ Python-pickle protocol on port 2004 ‱ Graphite is a WEB based GUI on top of Carbon ‱ Some Dashboard functionality
  • 6. Grafana ‱ Grafana is more Dashboard focused ‱ Grafana can use many Time-Series data sources ‱ Graphite ‱ Elasticsearch ‱ CloudWatch ‱ InfluxDB ‱ OpenTSDB ‱ KairosDB ‱ Prometheus
  • 8. Why use Carbon? Carbon provides an extremely simple protocol to send Time-Series data #!/bin/sh CHOST=”graphite.host.name” CPORT=”2003” METRIC=”test.PI” VALUE=”3.1415” echo ”$METRIC $VALUE ‘date +%s‘” | nc $CHOST $CPORT
  • 10. Why use Carbon? Not a very useful metric, but consider capturing the runtime of a shell script based cron job. Carbon also provides a Python-pickle based protocol on port 2004 that can be used to send hundreds of metric points condensed in one send(1).
  • 11. Why use Graphite AND Grafana? ‱ Grafana is more Dashboard focused ‱ Templating makes it easy to define one Dashboard and use it for many hosts/databases ‱ Getting to a Dashboard is easier ‱ Can define Alerts ‱ Looks cool ‱ Graphite is better at ad-hoc graphing ‱ The metric tree is easier to navigate than clicking through Grafana’s pull down system
  • 12. However 
 This isn’t a talk advertising Graphite or Grafana. This is a talk about capturing monitoring data from PostgreSQL and delivering it into a Time-Series data system. Carbon/Graphite and Grafana are example destinations.
  • 13. PostgreSQL Metric Data PostreSQL produces quite a number of data points. ‱ On the table level ‱ about 30 metric points ‱ On the index level ‱ about 6 metric points ‱ On the database level ‱ about 20 metric points
  • 14. PostgreSQL Metric Data Those per table/index numbers are not of concern when you look at your typical benchmark database. But what about a database with 1,800 tables and 13,000 indexes? Now we are talking about 132,000 metric points every time interval! Captured every minute that is 7.9M per hour, 190M per day, 17.1B per quarter. Don’t do that with snapshots captured inside the DB.
  • 15. PostgreSQL Metric Data That isn’t as exotic as it looks at first glance PostgreSQL system views like pg_stat_all_user_tables will report every single metric point even if a table or index hasn’t been used for the past 12 months. How many dead tables (schemas) does your database have? A generic monitoring system can’t tell them apart.
  • 16. PostgreSQL Metric Data But that isn’t all. Many metrics are presented in what is a continuous counter, but the useful value is actually their increase per second. Examples: ‱ Tuples inserted, updated, deleted, fetched ‱ Index/Sequential scans This is the same as for OS statistics like: ‱ Network operations ‱ Disk operations
  • 17. PostgreSQL Metric Data While that is efficient inside of the PostgreSQL server for collecting the data, it is rather inconvenient when browsing it in a system like Graphite or Grafana. Sure, they can apply a function like “persecond()” and it is only 20 mouse clicks away 

  • 18. OpenCollector ‱ OpenCollector is a PostgreSQL monitoring daemon sponsored by OpenSCG ‱ It is designed to address the aforementioned problems ‱ JSON configuration files define all the operation ‱ Target Carbon server ‱ Source Database(s) ‱ Queries to run and what metrics they return ‱ Sparse metric reporting
  • 19. OpenCollector An example from the sample configs: ”name”: ”global_stats”, ”prefix”: ”database:{datname}.global_stats”, ”query”: [ ”SELECT ”, ” datname, numbackends::float8, ”, ” xact_commit::float8, xact_rollback::float8, ”, ” blks_read::float8, blks_hit::float8, ”, ” pg_catalog.pg_database_size(datid)::float8, ”, ” pg_xlog_location_diff(pg_current_xlog_insert_location(), ”FROM pg_catalog.pg_stat_database ”, ”WHERE datname = current_database() ” ], ”result”: [ { ”name”: ”datname”, ”type”: ”internal” }, { ”name”: ”numbackends”, ”type”: ”value” }, { ”name”: ”xact_commit”, ”type”: ”counter” }, ... ]
  • 20. OpenCollector ‱ Since the queries are in config files, you can customize them ‱ Additional WHERE clauses ‱ Change from pg_stat_all_ to pg_stat_user_ ‱ Add your own, application specific queries ‱ OpenCollector is modular and allows to add other things ‱ OpenCollector is open source
  • 21. osinfofdw ‱ osinfofdw is another open source project sponsored by OpenSCG ‱ A MultiCorn based FDW around Python-psutil ‱ Access OS level statistics via SELECT ‱ CPU usage ‱ Memory usage ‱ Disk IO ‱ Network IO ‱ Filesystem information