server

package
v0.132.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllTargetsByCollectorAndJob

func GetAllTargetsByCollectorAndJob(allocator allocation.Allocator, collectorName string, jobName string) []*targetJSON

GetAllTargetsByCollector returns all the targets for a given collector and job.

func GetAllTargetsByJob

func GetAllTargetsByJob(allocator allocation.Allocator, job string) map[string]collectorJSON

GetAllTargetsByJob is a relatively expensive call that is usually only used for debugging purposes.

func RemoveRegexFromRelabelAction

func RemoveRegexFromRelabelAction(jsonConfig []byte) ([]byte, error)

RemoveRegexFromRelabelAction is needed specifically for keepequal/dropequal actions because even though the user doesn't specify the regex field for these actions the unmarshalling implementations of prometheus adds back the default regex fields which in turn causes the receiver to error out since the unmarshaling of the json response doesn't expect anything in the regex fields for these actions. Adding this as a fix until the original issue with prometheus unmarshaling is fixed - https://github.com/prometheus/prometheus/issues/12534

func WriteHTMLBadRequest added in v0.129.1

func WriteHTMLBadRequest(w io.Writer, br BadRequestData)

WriteHTMLBadRequest writes the bad request page.

func WriteHTMLNotFound added in v0.129.1

func WriteHTMLNotFound(w io.Writer, nf NotFoundData)

WriteHTMLNotFound writes the not found page.

func WriteHTMLPageFooter added in v0.129.1

func WriteHTMLPageFooter(w io.Writer)

WriteHTMLPageFooter writes the footer.

func WriteHTMLPageHeader added in v0.129.1

func WriteHTMLPageHeader(w io.Writer, hd HeaderData)

WriteHTMLPageHeader writes the header.

func WriteHTMLPropertiesTable added in v0.129.1

func WriteHTMLPropertiesTable(w io.Writer, chd PropertiesTableData)

WriteHTMLPropertiesTable writes the HTML for properties table.

Types

type BadRequestData added in v0.129.1

type BadRequestData struct {
	Error   string
	Example string
}

BadRequestData contains data for the bad request template.

type Cell added in v0.129.1

type Cell struct {
	// Link is the URL to link to. If empty, no link is created.
	Link string
	// Text is the text to display in the cell.
	Text string
	// Preformatted indicates if the text should be displayed as preformatted text.
	Preformatted bool
}

Cell represents a cell in a row.

func NewCell added in v0.129.1

func NewCell(text string) Cell

func Text added in v0.129.1

func Text(text string) Cell

type HeaderData added in v0.129.1

type HeaderData struct {
	Title string
}

HeaderData contains data for the header template.

type NotFoundData added in v0.129.1

type NotFoundData struct {
	ResourceType string
	ResourceName string
}

BadRequestData contains data for the bad request template.

type Option

type Option func(*Server)

func WithTLSConfig

func WithTLSConfig(tlsConfig *tls.Config, httpsListenAddr string) Option

Option to create an additional https server with mTLS configuration. Used for getting the scrape config with real secret values.

type PropertiesTableData added in v0.129.1

type PropertiesTableData struct {
	Headers []string
	Rows    [][]Cell
}

PropertiesTableData contains data for properties table template.

type Server

type Server struct {
	ScrapeConfigMarshalledSecretResponse []byte
	// contains filtered or unexported fields
}

func NewServer

func NewServer(log logr.Logger, allocator allocation.Allocator, listenAddr string, options ...Option) (*Server, error)

func (*Server) CollectorHTMLHandler added in v0.129.1

func (s *Server) CollectorHTMLHandler(c *gin.Context)

func (*Server) IndexHandler added in v0.129.1

func (s *Server) IndexHandler(c *gin.Context)

IndexHandler displays the main page of the allocator. It shows the number of jobs and targets. It also displays a table with the collectors and the number of jobs and targets for each collector. The collector names are links to the respective pages. The table is sorted by collector name.

func (*Server) JobHTMLHandler added in v0.129.1

func (s *Server) JobHTMLHandler(c *gin.Context)

func (*Server) JobsHTMLHandler added in v0.129.1

func (s *Server) JobsHTMLHandler(c *gin.Context)

JobsHTMLHandler displays the jobs in a table format. Each job is a row in the table. The table has two columns: Job and Target Count. The Job column is a link to the job's targets.

func (*Server) JobsHandler added in v0.129.1

func (s *Server) JobsHandler(c *gin.Context)

func (*Server) LivenessProbeHandler

func (s *Server) LivenessProbeHandler(c *gin.Context)

func (*Server) MarshalScrapeConfig

func (s *Server) MarshalScrapeConfig(configs map[string]*promconfig.ScrapeConfig, marshalSecretValue bool) error

func (*Server) PrometheusMiddleware

func (s *Server) PrometheusMiddleware(c *gin.Context)

func (*Server) ReadinessProbeHandler

func (s *Server) ReadinessProbeHandler(c *gin.Context)

func (*Server) ScrapeConfigsHTMLHandler added in v0.129.1

func (s *Server) ScrapeConfigsHTMLHandler(c *gin.Context)

func (*Server) ScrapeConfigsHandler

func (s *Server) ScrapeConfigsHandler(c *gin.Context)

ScrapeConfigsHandler returns the available scrape configuration discovered by the target allocator.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

func (*Server) ShutdownHTTPS

func (s *Server) ShutdownHTTPS(ctx context.Context) error

func (*Server) Start

func (s *Server) Start() error

func (*Server) StartHTTPS

func (s *Server) StartHTTPS() error

func (*Server) TargetHTMLHandler added in v0.129.1

func (s *Server) TargetHTMLHandler(c *gin.Context)

TargetHTMLHandler displays information about a target in a table format. There are two tables: one for high-level target information and another for the target's labels.

func (*Server) TargetsHTMLHandler added in v0.129.1

func (s *Server) TargetsHTMLHandler(c *gin.Context)

TargetsHTMLHandler displays the targets in a table format. Each target is a row in the table. The table has four columns: Job, Target, Collector, and Endpoint Slice. The Job, Target, and Collector columns are links to the respective pages.

func (*Server) TargetsHandler

func (s *Server) TargetsHandler(c *gin.Context)

func (*Server) UpdateScrapeConfigResponse

func (s *Server) UpdateScrapeConfigResponse(configs map[string]*promconfig.ScrapeConfig) error

UpdateScrapeConfigResponse updates the scrape config response. The target allocator first marshals these configurations such that the underlying prometheus marshaling is used. After that, the YAML is converted in to a JSON format for consumers to use.

Jump to

Keyboard shortcuts

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