gocdexporter

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2021 License: MIT Imports: 15 Imported by: 0

README

Prometheus GoCD exporter

Import statistics about GoCD pipelines and expose them to Prometheus. First draft based on https://github.com/leprechaun/gocd-prometheus-exporter

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentJobHistory added in v0.8.0

type AgentJobHistory struct {
	AgentJobHistory map[string][]*JobHistory
}

func (*AgentJobHistory) Add added in v0.8.0

func (a *AgentJobHistory) Add(agent string, jobHistory *JobHistory)

func (*AgentJobHistory) GetJobHistory added in v0.8.0

func (a *AgentJobHistory) GetJobHistory(client gocd.Client, agents []*gocd.Agent, cache AgentJobHistoryCache) error

type AgentJobHistoryCache added in v0.7.0

type AgentJobHistoryCache map[string]string

type CCTray

type CCTray struct {
	Projects []CCTrayProject `xml:"Project"`
}

func ParseCCTray

func ParseCCTray(input io.Reader) (*CCTray, error)

ParseCCTray expects the cctray.xml contents as input.

func RequestCCTray

func RequestCCTray(ctx context.Context, url, user, pass string) (*CCTray, error)

RequestCCTray performs basic auth against provided URL and calls ParseCCTray.

type CCTrayCache

type CCTrayCache struct {
	// contains filtered or unexported fields
}

CCTrayCache keeps a cache of CCTray.

func NewCCTrayCache

func NewCCTrayCache(url, user, pass string) *CCTrayCache

func (*CCTrayCache) Get

func (cache *CCTrayCache) Get(ctx context.Context) (*CCTray, error)

Get cached CCTray.

func (*CCTrayCache) Update

func (cache *CCTrayCache) Update(ctx context.Context) error

Update the CCTray cache.

type CCTrayProject

type CCTrayProject struct {
	Name       string `xml:"name,attr"`
	Activity   string `xml:"activity,attr"`
	LastResult string `xml:"lastBuildStatus,attr"`
	URL        string `xml:"webUrl,attr"`
	// contains filtered or unexported fields
}

func (CCTrayProject) Instance

func (p CCTrayProject) Instance() int64

Instance number parsed from webURL attribute. Returns -1 on errors.

func (CCTrayProject) Job added in v0.7.0

func (p CCTrayProject) Job() string

Job extracted from name attribute

func (CCTrayProject) Pipeline

func (p CCTrayProject) Pipeline() string

Pipeline extracted from name attribute.

func (CCTrayProject) Stage

func (p CCTrayProject) Stage() string

Stage extracted from name attribute.

type Config

type Config struct {
	Namespace  string
	Registerer prometheus.Registerer
	GocdURL    string
	GocdUser   string
	GocdPass   string
}

Config for the Scraper.

type JobHistory added in v1.1.1

type JobHistory struct {
	*gocd.AgentJobHistory
}

func (*JobHistory) GetOrderedStateTransitions added in v1.1.1

func (j *JobHistory) GetOrderedStateTransitions() []gocd.AgentJobStateTransition

type MockClient added in v0.7.0

type MockClient struct {
	// contains filtered or unexported fields
}

func NewMockClient added in v1.1.0

func NewMockClient() *MockClient

func (*MockClient) AgentRunJobHistory added in v0.7.0

func (c *MockClient) AgentRunJobHistory(uuid string, offset int, pageSize int) (*gocd.AgentJobRunHistory, error)

func (*MockClient) DeleteAgent added in v0.7.0

func (c *MockClient) DeleteAgent(uuid string) error

func (*MockClient) DisableAgent added in v0.7.0

func (c *MockClient) DisableAgent(uuid string) error

func (*MockClient) EnableAgent added in v0.7.0

func (c *MockClient) EnableAgent(uuid string) error

func (*MockClient) GetAgent added in v0.7.0

func (c *MockClient) GetAgent(uuid string) (*gocd.Agent, error)

func (*MockClient) GetAllAgents added in v0.7.0

func (c *MockClient) GetAllAgents() ([]*gocd.Agent, error)

func (*MockClient) GetAllEnvironmentConfigs added in v0.7.0

func (c *MockClient) GetAllEnvironmentConfigs() ([]*gocd.EnvironmentConfig, error)

func (*MockClient) GetEnvironmentConfig added in v0.7.0

func (c *MockClient) GetEnvironmentConfig(name string) (*gocd.EnvironmentConfig, error)

func (*MockClient) GetJobHistory added in v0.7.0

func (c *MockClient) GetJobHistory(pipeline, stage, job string) ([]*gocd.JobHistory, error)

func (*MockClient) GetPipelineGroups added in v0.7.0

func (c *MockClient) GetPipelineGroups() ([]*gocd.PipelineGroup, error)

func (*MockClient) GetPipelineHistoryPage added in v0.7.0

func (c *MockClient) GetPipelineHistoryPage(string, int) (*gocd.PipelineHistoryPage, error)

func (*MockClient) GetPipelineInstance added in v0.7.0

func (c *MockClient) GetPipelineInstance(string, int) (*gocd.PipelineInstance, error)

func (*MockClient) GetPipelineStatus added in v0.7.0

func (c *MockClient) GetPipelineStatus(string) (*gocd.PipelineStatus, error)

func (*MockClient) GetScheduledJobs added in v0.7.0

func (c *MockClient) GetScheduledJobs() ([]*gocd.ScheduledJob, error)

func (*MockClient) GetServerHealthMessages added in v1.2.0

func (c *MockClient) GetServerHealthMessages() ([]*gocd.ServerHealthMessage, error)

func (*MockClient) PausePipeline added in v0.7.0

func (c *MockClient) PausePipeline(string, string) (*gocd.SimpleMessage, error)

func (*MockClient) UnlockPipeline added in v0.7.0

func (c *MockClient) UnlockPipeline(string) (*gocd.SimpleMessage, error)

func (*MockClient) UnpausePipeline added in v0.7.0

func (c *MockClient) UnpausePipeline(string) (*gocd.SimpleMessage, error)

func (*MockClient) UpdateAgent added in v0.7.0

func (c *MockClient) UpdateAgent(uuid string, agent *gocd.Agent) (*gocd.Agent, error)

type PipelineGroups added in v1.1.0

type PipelineGroups struct {
	// contains filtered or unexported fields
}

func (*PipelineGroups) GetPipelineGroup added in v1.1.0

func (pg *PipelineGroups) GetPipelineGroup(client gocd.Client, pipeline string) (string, error)

type Scraper

type Scraper func(context.Context) error

Scraper runs one scrape loop for collecting metrics.

func NewScraper

func NewScraper(conf *Config) (Scraper, error)

NewScraper configures prometheus metrics to be scraped from GoCD.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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