opa

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package opa provides prometheus metrics for OPA and methods

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportConstraintInformation

func ExportConstraintInformation(ci *prometheus.Desc, constraints []Constraint) []prometheus.Metric

func ExportViolations

func ExportViolations(ctx context.Context, cv *prometheus.Desc, constraints []Constraint) []prometheus.Metric

Types

type Constraint

type Constraint struct {
	Meta   ConstraintMeta
	Spec   ConstraintSpec
	Status ConstraintStatus
}

func GetConstraints

func GetConstraints(ctx context.Context, inCluster *bool) ([]Constraint, error)

GetConstraints returns a list of all OPA constraints nolint:gocognit // would be nice to reduce complexity - I don't see a straightforward path ATM.

type ConstraintMeta

type ConstraintMeta struct {
	Kind string
	Name string
}

ConstraintMeta represents meta information of a constraint

type ConstraintSpec

type ConstraintSpec struct {
	EnforcementAction string `json:"enforcementAction"`
}

ConstraintSpec collect general information about the overall constraints applied to the cluster

type ConstraintStatus

type ConstraintStatus struct {
	TotalViolations float64 `json:"totalViolations,omitempty"`
	Violations      []*Violation
}

type Exporter

type Exporter struct {
	ConstraintInformation *prometheus.Desc
	ConstraintViolation   *prometheus.Desc
	Metrics               []prometheus.Metric
	Namespace             string
	Up                    *prometheus.Desc
}

func NewExporter

func NewExporter(cfg config.Config) *Exporter

func (*Exporter) Collect

func (e *Exporter) Collect(ch chan<- prometheus.Metric)

func (*Exporter) Describe

func (e *Exporter) Describe(ch chan<- *prometheus.Desc)

type Violation

type Violation struct {
	Kind              string `json:"kind"`
	Name              string `json:"name"`
	Namespace         string `json:"namespace,omitempty"`
	Message           string `json:"message"`
	EnforcementAction string `json:"enforcementAction"`
}

Violation represents each constraintViolation under status

Jump to

Keyboard shortcuts

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