Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Prometheus Receiver UI for Viewing Targets/Service Discovery/Config #63

Open
@gracewehner

Description

@gracewehner

Currently, authoring scrape configs or debugging issues with scrape configs can be difficult and has a learning curve using just the debug logs of the prometheus receiver.

Prometheus has a web UI with the pages Targets, Service Discovery, and Configuration for this:
targets (2)
service-discovery (3)

This UI uses html templates with the data filled by calling the scrape manager's functions. The prometheus receiver is using the same scrape manager in metrics_receiver.go, so the same functions to get the same data can be called to have an optional, similar UI.

A config option can be added for the prometheus receiver to enable hosting the UI as a local endpoint. The code that enables this would be in the Start() function of metrics_receiver.go, where the scrapeManager is created and run:

webOptions := web.Options{
	ScrapeManager: scrapeManager,
	Context: ctxWeb,
	ListenAddress: ":9090",
	ExternalURL: &url.URL{
		Scheme: "http",
		Host:   "localhost:9090",
		Path:   "",
	},
	RoutePrefix:    "/",
	ReadTimeout: time.Second * 30,
	PageTitle: "Prometheus Receiver",
	Version: &web.PrometheusVersion{
		Version:   version.Version,
		Revision:  version.Revision,
		Branch:    version.Branch,
		BuildUser: version.BuildUser,
		BuildDate: version.BuildDate,
		GoVersion: version.GoVersion,
	},
	MaxConnections: 5,
} 
webHandler := web.New(go_kit_logger, &webOptions)
listener, err := webHandler.Listener()
if err != nil {
	return errors.Wrapf(err, "error creating listener")
}
webHandler.ApplyConfig(r.cfg.PrometheusConfig)
webHandler.Ready()
go func() {
	if err := webHandler.Run(ctxWeb, listener, ""); err != nil {
		return errors.Wrapf(err, "error starting web server")
	}
}()

I currently have two different proof of concepts:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions