[go: up one dir, main page]

exp

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

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

Go to latest
Published: Jun 25, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

README

client_golang experimental module

Contains experimental utilities and APIs for Prometheus. The module may be contain breaking changes or be removed in the future.

Packages within this module are listed below.

Remote

Implements bindings from Prometheus remote APIs (remote write v1 and v2 for now).

Contains flexible method for building API clients, that can send remote write protocol messages.

    import (
        "github.com/prometheus/client_golang/exp/api/remote"
    )
    ...

	remoteAPI, err := remote.NewAPI(
		"https://your-remote-endpoint",
		remote.WithAPIHTTPClient(httpClient),
		remote.WithAPILogger(logger.With("component", "remote_write_api")),
	)
    ...

    stats, err := remoteAPI.Write(ctx, remote.WriteV2MessageType, protoWriteReq)

Also contains handler methods for applications that would like to handle and store remote write requests.

    import (
        "net/http"
        "log"

        "github.com/prometheus/client_golang/exp/api/remote"
    )
    ...
    
    type db {}

    func NewStorage() *db {}

    func (d *db) Store(ctx context.Context, msgType remote.WriteMessageType, req *http.Request) (*remote.WriteResponse, error) {}
    ...

	mux := http.NewServeMux()

	remoteWriteHandler := remote.NewHandler(storage, remote.WithHandlerLogger(logger.With("component", "remote_write_handler")))
	mux.Handle("/api/v1/write", remoteWriteHandler)

	server := &http.Server{
		Addr:    ":8080",
		Handler: mux,
	}
	if err := server.ListenAndServe(); err != nil {
		log.Fatal(err)
	}

For more details, see go doc.

Documentation

Overview

package exp contains experimental utilities and APIs for Prometheus.

This package is experimental and may contain breaking changes or be removed in the future.

Directories

Path Synopsis
api
remote
Package remote implements bindings for Prometheus Remote APIs.
Package remote implements bindings for Prometheus Remote APIs.
internal
github.com/efficientgo/core/backoff
Package backoff implements backoff timers which increases wait time on every retry, incredibly useful in distributed system timeout functionalities.
Package backoff implements backoff timers which increases wait time on every retry, incredibly useful in distributed system timeout functionalities.
github.com/planetscale/vtprotobuf/protohelpers
Package protohelpers provides helper functions for encoding and decoding protobuf messages.
Package protohelpers provides helper functions for encoding and decoding protobuf messages.

Jump to

Keyboard shortcuts

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