Skip to content
This repository has been archived by the owner on Sep 26, 2020. It is now read-only.
/ caddyprom Public archive

⚠️ DEPRECATED - use the core metrics supported in Caddy v2.2.0-rc.2+

License

Notifications You must be signed in to change notification settings

hairyhenderson/caddyprom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ This module is deprecated! Caddy v2.2.0 (and later) contains built-in metrics support.

📣 Now that Caddy v2.2.0 has been released, I will be archiving this repository. Thanks to everyone for using and contributing to this module! It has been invaluable in making decisions toward metrics in Caddy's core!

Prometheus metrics module for Caddy v2

This implements a Caddy v2 module that exposes metrics in the Prometheus format.

To use this module, you must build a Caddy binary with the module compiled in. Use xcaddy for this.

Usage

Caddyfile

The simplest use could be in a Caddyfile like:

{
    order prometheus first
}

localhost

prometheus

JSON config

Here is an example that tracks metrics for Caddy's reverse_proxy module as well:

{
    "apps": {
        "http": {
            "servers": {
                "srv0": {
                    "listen": [
                        ":443"
                    ],
                    "routes": [
                        {
                            "handle": [
                                {
                                    "handler": "subroute",
                                    "routes": [
                                        {
                                            "handle": [
                                                {
                                                    "handler": "prometheus"
                                                },
                                                {
                                                    "handler": "reverse_proxy",
                                                    "upstreams": [
                                                        {
                                                            "dial": "10.0.0.1:80"
                                                        },
                                                        {
                                                            "dial": "10.0.0.2:80"
                                                        }
                                                    ]
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ],
                            "match": [
                                {
                                    "host": [
                                        "redacted.mycompany.com"
                                    ]
                                }
                            ],
                            "terminal": true
                        }
                    ]
                }
            }
        }
    }
}

Get metrics

Then, when using a Caddy server with this module enabled:

$ curl localhost/
$ curl localhost:9180/metrics
...
caddy_http_response_size_bytes_sum{code="418",method="get"} 42
...

License

The MIT License

Copyright (c) 2020 Dave Henderson

About

⚠️ DEPRECATED - use the core metrics supported in Caddy v2.2.0-rc.2+

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages