advanced_metrics

package module
v0.0.0-...-ba7505b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 8 Imported by: 0

README

caddy-advanced-metrics

Metric your Caddy servers using Prometheus and Grafana with this simple plugin. It provided per-host metrics for your servers and more useful metrics.

Report Bug - Request Feature

Downloads Contributors Stargazers Issues License

About The Project

With this caddy module built on bases of xcaddy you can easily monitor your caddy servers using Prometheus and Grafana. It provides per-host metrics for your servers and more useful metrics. It is possible to monitor your hosts on the same Prometheus port.

Built With

  • xcaddy
  • Prometheus Go client library

Getting Started

Usage

{
	order advanced_metrics before file_server
  order advanced_metrics before reverse_proxy
}

:8080 {
    # Enable advanced metrics on port 1234 (http://localhost:1234/metrics)
    advanced_metrics {
      port 1234
    }

    # Enable file server
    file_server
}

:8081 {
    # Enable advanced metrics (default port 6611)
    advanced_metrics

    # Enable file server
    file_server
}

Download build

You can download the latest build from the releases page.

Prerequisites

  • Golang
  • xcaddy

Build and run

  1. Clone the repository
git clone https://github.com/sebastianbrunnert/caddy-advanced-metrics.git
  1. Install Golang dependencies
go mod download
  1. Build custom caddy binary using xcaddy
make build
  1. Run custom caddy binary

Now you can run your custom caddy binary with the advanced metrics module. You can use the following command to run the binary:

./caddy run --config ./examples/Caddyfile

or you can setup the caddy service using systemd.

nano /usr/lib/systemd/system/caddy.service
[Service]
ExecStart=/path/to/caddy run --config /path/to/Caddyfile

Roadmap

See the open issues for a list of proposed features (and known issues).

License

Distributed under the MIT License. See LICENSE for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleRequest

func HandleRequest(port int, method string, path string, status int, host string)

func StartServer

func StartServer(port int)

Types

type AdvancedMetrics

type AdvancedMetrics struct {
	PrometheusPort int
}

func (AdvancedMetrics) CaddyModule

func (AdvancedMetrics) CaddyModule() caddy.ModuleInfo

func (AdvancedMetrics) ServeHTTP

func (AdvancedMetrics) UnmarshalCaddyfile

func (AdvancedMetrics) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

type LoggingResponseWriter

type LoggingResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func NewLoggingResponseWriter

func NewLoggingResponseWriter(w http.ResponseWriter) *LoggingResponseWriter

func (*LoggingResponseWriter) WriteHeader

func (lrw *LoggingResponseWriter) WriteHeader(code int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL