Giter Site home page Giter Site logo

simske / prometheus-metrics-in-wordpress Goto Github PK

View Code? Open in Web Editor NEW

This project forked from codeatcode/prometheus-metrics-in-wordpress

0.0 0.0 0.0 44 KB

Prometheus endpoint customizable for WordPress

License: GNU General Public License v3.0

PHP 100.00%

prometheus-metrics-in-wordpress's Introduction

Prometheus Metrics in WordPress

License

A WordPress plugin, based on https://github.com/CodeAtCode/WPDB-Status.

Grafana dashboard avalaible on official website.

Build project

  • You need Composer
  • Run composer update -o

Settings

In wp-config.php you need to settings that constant that will be used to expose those metrics in the url.

define( 'PROMETHEUS_KEY', 'fg98dfgkj' );

Prometheus

To add a new target:

  - job_name: "WordPress metrics"
    static_configs:
      - targets: ["domain.tld"]
    scrape_interval: "5m"
    metrics_path: "/wp-json/metrics"
    params:
      prometheus: ['fg98dfgkj']
      users: ['yes']
      posts: ['yes']
      pages: ['yes']
      autoload: ['yes']
      transient: ['yes']
      user_sessions: ['yes']
      posts_without_content: ['yes']
      posts_without_title: ['yes']
      db_size: ['yes']
      pending_updates: ['yes']
    scheme: "https"

WordPress customization

This plugin includes a hook to append new metrics: prometheus_custom_metrics

URL parameters

Enable all

all=yes enables all of the default filters at once

Enable or disable specific metrics

See the included page at Tools -> Site Health -> Prometheus with specific metric parameters.

Changelog

2.0

  • Major rewrite, which may break your current metrics!
  • Requires at least WordPress 5.6 and PHP 7.3
    • Added PHP 8.0 polyfill
  • Use 'gauge' instead of 'counter'
    • Define PROMETHEUS_LEGACY_TYPE with true to change this
  • Added more metrics
    • You can add custom metrics by implementing WP_Prometheus_Metrics\Metric
  • Added timestamps to metrics
  • Metrics will be cached for 1h by default (use filter prometheus-metrics-for-wp/timeout to change this)
  • Seperated metrics for different post types
  • Site health check integration
    • View url for endpoint
    • Ability to generate authentication keys

Legacy support

To use 'counter' instead of 'gauge', add the following to your wp-config.php

define('PROMETHEUS_LEGACY_TYPE', true);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.