gin_prometheus_pusher

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: MIT Imports: 5 Imported by: 0

README

gin_prometheus_pusher

A Gin Middleware that pushes to a Prometheus Instance instead of scraping it. Ideal for Serverless Applications

Index

Installation

go get github.com/fourhundredfour/gin_prometheus_pusher

Example

package main

import (
    "net/http"
    "github.com/gin-gonic/gin"
    "github.com/fourhundredfour/gin_prometheus_pusher"
)

func main() {
    engine := gin.Default()
	
    var configuration gin_prometheus_pusher.PrometheusConfiguration
    configuration.Address = "http://example.org/metrics"
    configuration.Job = "my_job"
    engine.Use(gin_prometheus_pusher.Prometheus(configuration))

    engine.GET("/", func(ctx *gin.Context) {
        context.JSON(http.StatusOK, nil)
    })
    http.ListenAndServe(":8080", engine)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Prometheus

func Prometheus(config PrometheusConfiguration) gin.HandlerFunc

Types

type PrometheusConfiguration

type PrometheusConfiguration struct {
	Collectors        *[]prometheus.Collector // User defined Collectors
	Gatherers         *[]prometheus.Gatherer  // User defined Gatherers
	Job               string                  // Job Name
	Address           string                  // Address of the Prometheus Push Gateway
	BasicAuthUser     string                  // Http Basic Auth User
	BasicAuthPassword string                  // Http Basic Auth Password
	AfterRequest      bool                    // Push metrics before request
	BeforeRequest     bool                    // Push metrics after request
}

Jump to

Keyboard shortcuts

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