service

package
v0.0.0-...-f27324f Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package service provides prometheus service for user to query metrics.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ServiceInfo handles normal service running in the k8s
	ServiceInfo *kubeInfo
	// IstioInfo handles istio service running in the k8s
	IstioInfo *kubeInfo
)
View Source
var Prom *prom

Prom wraps prom service for easily use.

View Source
var Task task

Task wraps task service for easily use.

View Source
var TaskTmpl taskTmpl

TaskTmpl wraps task service for easily use.

View Source
var TaskTmplVar taskTmplVar

TaskTmplVar wraps task service for easily use.

Functions

func GenerateD3JSON

func GenerateD3JSON(w io.Writer, g *Dynamic) error

GenerateD3JSON converts the standard Dynamic graph to d3Graph, then serializes to JSON.

func Init

func Init()

Init initializes service pkg.

func InitKube

func InitKube()

InitKube initializes kube.

func InitProm

func InitProm()

InitProm initializes prometheus service.

func NewPromHandler

func NewPromHandler(addr string, static *Static, writer SerializeFn) http.Handler

NewPromHandler returns a new http.Handler that will serve servicegraph data based on queries against a prometheus backend.

Types

type Attributes

type Attributes map[string]string

Attributes contain a set of annotations for an edge.

type Dynamic

type Dynamic struct {
	Nodes map[string]struct{} `json:"nodes"`
	Edges []*Edge             `json:"edges"`
}

Dynamic represents a service graph generated on the fly.

func (*Dynamic) AddEdge

func (d *Dynamic) AddEdge(src, target string, lbls map[string]string)

AddEdge adds a new edge to an existing dynamic graph.

func (*Dynamic) Merge

func (d *Dynamic) Merge(static *Static)

Merge adds all of the nodes in the static graph into the dynamic graph.

type Edge

type Edge struct {
	Source string     `json:"source"`
	Target string     `json:"target"`
	Labels Attributes `json:"labels"`
}

Edge represents an edge in a dynamic service graph.

type Graph

type Graph struct {
	Nodes map[string]struct{} `json:"nodes"`
	Edges []*Edge             `json:"edges"`
}

Graph represents a service graph generated.

func (*Graph) AddEdge

func (g *Graph) AddEdge(src, target string, lbls map[string]string)

AddEdge adds a new edge to an existing dynamic graph.

type KubePodStatus

type KubePodStatus struct {
	UID      string `json:"uid"`
	Name     string `json:"name"`
	Ready    string `json:"ready"`
	Status   string `json:"status"` // Pending、Running、Succeeded、Failed、Unknown
	Restarts int    `json:"restarts"`
	Age      string `json:"age"`
}

KubePodStatus defines pods' status of specific service.

type KubeServiceStatus

type KubeServiceStatus struct {
	UID        string `json:"uid"`
	Name       string `json:"name"`
	Type       string `json:"type"`
	ClusterIP  string `json:"clusterIP"`
	ExternalIP string `json:"externalIP"`
	Ports      string `json:"ports"`
	Age        string `json:"age"`
}

KubeServiceStatus defines services' status of specific service.

type SerializeFn

type SerializeFn func(w io.Writer, g *Dynamic) error

SerializeFn provides a mechanism for writing out the service graph.

type Static

type Static struct {
	Nodes map[string]struct{}
}

Static represents a service graph generated by API calls that is meant to persist across generation requests. It must be merged with a Dynamic graph to provide a complete service graph for Istio.

type Tree

type Tree struct {
	Title         string `json:"title"`
	Key           string `json:"key"`
	GraphNodeName string `json:"graphNodeName"`
	Namespace     string `json:"namespace"`
	Children      []Tree `json:"children"`
}

Tree wraps k8s service tree

Jump to

Keyboard shortcuts

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