utils

package
v0.0.0-...-c1bde5a Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFederationHostsFromConfig

func GetFederationHostsFromConfig(path string) ([]string, error)

GetFederationHostsFromConfig read prometheus config file and return all target for federation, only static_config support

func GetGraph

func GetGraph(pn *PrometheusNode) func(w http.ResponseWriter, r *http.Request)

GetGraph will return a http handler function which encode current node info to json response

func GetNextProxyHeader

func GetNextProxyHeader(r *http.Request) ([]string, error)

GetNextProxyHeader will parse the request header and send request to next agent based header infomation

func MakePrometheusRequest

func MakePrometheusRequest(r *http.Request) (string, error)

MakePrometheusRequest send http request

func MakeRequest

func MakeRequest(url string, header map[string]string) (string, error)

MakeRequest make http request with headers

func UpdateGraph

func UpdateGraph(pn *PrometheusNode) func(w http.ResponseWriter, r *http.Request)

UpdateGraph will insert or update a node from post data

Types

type PrometheusNode

type PrometheusNode struct {
	Children         PrometheusNodeList `json:"children"`
	AgentStatus      bool               `json:"agent_status"`
	PrometheusStatus bool               `json:"prometheus_status"`
	PrometheusHost   string             `json:"prometheus_host"`
	AgentHost        string             `json:"agent_host"`
}

PrometheusNode will include current node infomations

func NewPrometheusNode

func NewPrometheusNode(prometheusHost string) (*PrometheusNode, error)

NewPrometheusNode create a new node with children nodes

func (*PrometheusNode) DeleteNodeByHost

func (pn *PrometheusNode) DeleteNodeByHost(host string) bool

DeleteNodeByHost will delete from graph by host name

func (*PrometheusNode) InsertOrUpdate

func (pn *PrometheusNode) InsertOrUpdate(newNode *PrometheusNode, search bool)

InsertOrUpdate will insert new node if not exist or update exist if search exist in its tree

func (*PrometheusNode) Ping

func (pn *PrometheusNode) Ping()

Ping will send request to each children and get back the response

func (*PrometheusNode) PrintNodesTree

func (pn *PrometheusNode) PrintNodesTree(prefix string, depth int, withStatus bool) string

PrintNodesTree print out the struct of nodes

func (*PrometheusNode) Search

func (pn *PrometheusNode) Search(host string, recursive bool) bool

Search will find the matched nodes and return true if exist

func (*PrometheusNode) SearchAndUpdateAgentStatus

func (pn *PrometheusNode) SearchAndUpdateAgentStatus(host string, recursive bool, status bool) bool

SearchAndUpdateAgentStatus will find the matched nodes and update agent status

func (*PrometheusNode) SearchAndUpdatePrometheusStatus

func (pn *PrometheusNode) SearchAndUpdatePrometheusStatus(host string, recursive bool, status bool) bool

SearchAndUpdatePrometheusStatus will find the matched nodes and update prometheus status

type PrometheusNodeList

type PrometheusNodeList []*PrometheusNode

PrometheusNodeList list of many prometheus node

func NewPrometheusNodeList

func NewPrometheusNodeList(feds []string) PrometheusNodeList

NewPrometheusNodeList create nodes list for management

Jump to

Keyboard shortcuts

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