codeatcode / prometheus-metrics-in-wordpress Goto Github PK
View Code? Open in Web Editor NEWPrometheus endpoint customizable for WordPress
License: GNU General Public License v3.0
Prometheus endpoint customizable for WordPress
License: GNU General Public License v3.0
Hi there,
first of all thanks for this plugin โ I'm not using it myself but like the idea. I'm opening this PR because I think you should consider to use gauges
instead of counters
. According the the prometheus documentation:
A gauge is a metric that represents a single numerical value that can arbitrarily go up and down.
A counter is a cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero on restart.
As posts and pages can be deleted, I would say that a gauge is most appropriated in most cases. This stackoverflow post is worth reading.
Hope this helps !
Hello, I have a few setup questions:
I installed this plugin, created a key, and wrote a job for prometheus. It connects and shows the up status
Clicking on the link, as I understand it with metrics
http://192.168.10.49:8080/wp-json/metrics?autoload=yes&db_size=yes&pages=yes&pending_updates=yes&posts=yes&posts_without_content=yes&posts_without_title=yes&prometheus=9c136101-43e4-4a05-8069-0c4461e34a7a&transient=yes&user_sessions=yes&users=yes
I get a black screen
I guess I need to configure InfluxDB and see an example, but I don't understand what values need to be passed
bucket id hosting Vendor hosting Rate
P.S. I deploy wordpress locally as an experiment without using domains, wordpress is located on 192.168.10.49:8080
Hello,
Could the plugin return the WordPress version as a metric?
This is something various exporters do via an _info
metric:
The Prometheus Proxmox VE Exporter:
pve_version_info{instance="pve.example.com:9221",job="pve",release="7.3",repoid="d69b70d4",version="7.3-4"} 1
The Node exporter:
go_info{instance="foo.example.com:9100",job="node",version="go1.11.6"} 1
I've also done it on self-made applications:
mycompany_app_info{instance="app.example.com:443",job="app",version="42",build="ab2d3ef2ad62"} 1
The wp_info
could be used:
wp_info{host="https://wp.example.com",version="6.1.1"} 1
If it's OK with you I can open a PR for this.
As per title, I have the constant defined so should report the one already existing.
With difference between plugin and wordpress so we can add alerts.
as the title :-)
hi,
apologies for this but am a WordPress newbie. Just wanted to understand exactly what I needed to do to get the capability running.
I have,
but as expected am getting a 404 on wp-json/metrics
I am clearly missing some WordPress config but don't know what I am missing.
Any help appreciated
I installed the plugin and configured wp-config.php but when I go to https://<my-url>/wp-json/metrics?all=yes&prometheus=<my-key>
I get the message { "error": "You cannot access to that page" }
. How can I fix this issue?
I installed your plugin by first download the current master, made composer update -o
. Than I zipped the hole folder and uploaded it by using the interface of WP.
Did I reproduce anything of your documentation wrong?
I just don't see any other metric than this:
I hope, you can help me.
Meta:
WP Version: 6.2
There are some duplicates in the prometheus request with v2:
# HELP wp_posts_total Deprecated. Total number of posts published.
# TYPE wp_posts_total counter
wp_posts_total{host="https://domain.tld", status="published"} 16544
wp_posts_total{host="https://domain.tld", status="draft"} 25
# HELP wp_pages_total Deprecated. Total number of pages published.
# TYPE wp_pages_total counter
wp_pages_total{host="https://domain.tld", status="published"} 8
wp_pages_total{host="https://domain.tld", status="draft"} 0
# HELP wp_db_size Total DB size in MB
# TYPE wp_db_size gauge
wp_db_size{host="https://domain.tld"} 1103.93 1638445108000
# HELP wp_users_total Total number of users
# TYPE wp_users_total gauge
wp_users_total{host="https://domain.tld"} 133 1638445108000
# HELP wp_user_sessions User sessions
# TYPE wp_user_sessions gauge
wp_user_sessions{host="https://domain.tld"} 0 1638445108000
# HELP wp_options_autoload Options size in KB in autoload
# TYPE wp_options_autoload gauge
wp_options_autoload{host="https://domain.tld"} 351 1638445108000
# HELP wp_options_autoload_size Options in autoload
# TYPE wp_options_autoload_size gauge
wp_options_autoload_size{host="https://domain.tld"} 262 1638445108000
# HELP wp_posts_without_content Posts and Pages without content
# TYPE wp_posts_without_content gauge
wp_posts_without_content{host="https://domain.tld"} 15 1638445108000
# HELP wp_posts_without_title Posts and Pages without title
# TYPE wp_posts_without_title gauge
wp_posts_without_title{host="https://domain.tld"} 0 1638445108000
# HELP wp_post_types_total Total number of content by type and status
# TYPE wp_post_types_total gauge
wp_post_types_total{host="https://domain.tld",post_type="page",status="publish"} 8 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="publish"} 16544 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="future"} 28 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="draft"} 25 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="trash"} 48 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="auto-draft"} 22 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="attachment",status="trash"} 92 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="attachment",status="inherit"} 16461 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="publish"} 16544 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="future"} 28 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="draft"} 25 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="trash"} 48 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="auto-draft"} 22 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="attachment",status="trash"} 92 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="attachment",status="inherit"} 16461 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="chart",status="publish"} 2 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="chart",status="draft"} 1 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="people",status="publish"} 9266 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="people",status="draft"} 25 1638445108000
# HELP wp_pending_updates Pending updates in the WordPress website
# TYPE wp_pending_updates gauge
wp_pending_updates{host="https://domain.tld"} 1 1638445108000
# HELP wp_transient_autoload DB Transient in autoload.
# TYPE wp_transient_autoload gauge
wp_transient_autoload{host="https://domain.tld"} 4 1638445108000
# HELP perf_count_posts Measure the time in ns for a count query on the posts table
# TYPE perf_count_posts gauge
perf_count_posts{host="https://domain.tld"} 33892502 1638445108000
# HELP perf_write_temp_file Measure the time in ns of writing a large file
# TYPE perf_write_temp_file gauge
perf_write_temp_file{host="https://domain.tld"} 1840657292 1638445110000
# HELP wp_db_size Total DB size in MB
# TYPE wp_db_size gauge
wp_db_size{host="https://domain.tld"} 1103.93 1638445108000
# HELP wp_users_total Total number of users
# TYPE wp_users_total gauge
wp_users_total{host="https://domain.tld"} 133 1638445108000
# HELP wp_user_sessions User sessions
# TYPE wp_user_sessions gauge
wp_user_sessions{host="https://domain.tld"} 0 1638445108000
# HELP wp_options_autoload Options size in KB in autoload
# TYPE wp_options_autoload gauge
wp_options_autoload{host="https://domain.tld"} 351 1638445108000
# HELP wp_options_autoload_size Options in autoload
# TYPE wp_options_autoload_size gauge
wp_options_autoload_size{host="https://domain.tld"} 262 1638445108000
# HELP wp_posts_without_content Posts and Pages without content
# TYPE wp_posts_without_content gauge
wp_posts_without_content{host="https://domain.tld"} 15 1638445108000
# HELP wp_posts_without_title Posts and Pages without title
# TYPE wp_posts_without_title gauge
wp_posts_without_title{host="https://domain.tld"} 0 1638445108000
# HELP wp_post_types_total Total number of content by type and status
# TYPE wp_post_types_total gauge
wp_post_types_total{host="https://domain.tld",post_type="page",status="publish"} 8 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="publish"} 16544 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="future"} 28 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="draft"} 25 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="trash"} 48 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="auto-draft"} 22 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="attachment",status="trash"} 92 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="attachment",status="inherit"} 16461 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="publish"} 16544 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="future"} 28 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="draft"} 25 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="trash"} 48 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="post",status="auto-draft"} 22 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="attachment",status="trash"} 92 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="attachment",status="inherit"} 16461 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="chart",status="publish"} 2 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="chart",status="draft"} 1 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="people",status="publish"} 9266 1638445108000
wp_post_types_total{host="https://domain.tld",post_type="people",status="draft"} 25 1638445108000
# HELP wp_pending_updates Pending updates in the WordPress website
# TYPE wp_pending_updates gauge
wp_pending_updates{host="https://domain.tld"} 1 1638445108000
# HELP wp_transient_autoload DB Transient in autoload.
# TYPE wp_transient_autoload gauge
wp_transient_autoload{host="https://domain.tld"} 4 1638445108000
# HELP perf_count_posts Measure the time in ns for a count query on the posts table
# TYPE perf_count_posts gauge
perf_count_posts{host="https://domain.tld"} 33892502 1638445108000
# HELP perf_write_temp_file Measure the time in ns of writing a large file
# TYPE perf_write_temp_file gauge
perf_write_temp_file{host="https://domain.tld"} 1840657292 1638445110000
Looking at https://github.com/CodeAtCode/Prometheus-Metrics-in-WordPress/blob/v2/prometheus-metrics-for-wp.php#L136-143 the legacy and new one are printed but the new one include also legacy metrics so they are printed again. Removing those will simplify the parsing and downloading of that page (yeah not so many kb but we are talking metrics after all)
Maybe add a parameter to the prometheus_get_metrics
filter to specify legacy or not is the best way.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.