Started implementing configurable metrics model
This commit is contained in:
parent
fb9b96bf75
commit
dbac795ab0
|
|
@ -61,6 +61,9 @@ type AutoscalingListenerSpec struct {
|
|||
// +optional
|
||||
GitHubServerTLS *GitHubServerTLSConfig `json:"githubServerTLS,omitempty"`
|
||||
|
||||
// +optional
|
||||
Metrics *MetricsConfig `json:"metrics,omitempty"`
|
||||
|
||||
// +optional
|
||||
Template *corev1.PodTemplateSpec `json:"template,omitempty"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package v1alpha1
|
|||
|
||||
import (
|
||||
"crypto/x509"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
|
@ -74,6 +75,9 @@ type AutoscalingRunnerSetSpec struct {
|
|||
// Required
|
||||
Template corev1.PodTemplateSpec `json:"template,omitempty"`
|
||||
|
||||
// +optional
|
||||
ListenerMetrics *MetricsConfig `json:"metrics,omitempty"`
|
||||
|
||||
// +optional
|
||||
ListenerTemplate *corev1.PodTemplateSpec `json:"listenerTemplate,omitempty"`
|
||||
|
||||
|
|
@ -232,6 +236,29 @@ type ProxyServerConfig struct {
|
|||
CredentialSecretRef string `json:"credentialSecretRef,omitempty"`
|
||||
}
|
||||
|
||||
// MetricsConfig holds configuration parameters for each metric type
|
||||
type MetricsConfig struct {
|
||||
Counters map[string]*CounterMetric `json:"counters"`
|
||||
Gauges map[string]*GaugeMetric `json:"gauges"`
|
||||
Histograms map[string]*HistogramMetric `json:"histograms"`
|
||||
}
|
||||
|
||||
// CounterMetric holds configuration of a single metric of type Counter
|
||||
type CounterMetric struct {
|
||||
Labels []string `json:"labels"`
|
||||
}
|
||||
|
||||
// GaugeMetric holds configuration of a single metric of type Gauge
|
||||
type GaugeMetric struct {
|
||||
Labels []string `json:"labels"`
|
||||
}
|
||||
|
||||
// HistogramMetric holds configuration of a single metric of type Histogram
|
||||
type HistogramMetric struct {
|
||||
Labels []string `json:"labels"`
|
||||
Buckets []json.Number `json:"buckets,omitempty"`
|
||||
}
|
||||
|
||||
// AutoscalingRunnerSetStatus defines the observed state of AutoscalingRunnerSet
|
||||
type AutoscalingRunnerSetStatus struct {
|
||||
// +optional
|
||||
|
|
|
|||
|
|
@ -119,6 +119,55 @@ spec:
|
|||
description: Required
|
||||
minimum: 0
|
||||
type: integer
|
||||
metrics:
|
||||
description: MetricsConfig holds configuration parameters for each metric type
|
||||
properties:
|
||||
counters:
|
||||
additionalProperties:
|
||||
description: CounterMetric holds configuration of a single metric of type Counter
|
||||
properties:
|
||||
labels:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- labels
|
||||
type: object
|
||||
type: object
|
||||
gauges:
|
||||
additionalProperties:
|
||||
description: GaugeMetric holds configuration of a single metric of type Gauge
|
||||
properties:
|
||||
labels:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- labels
|
||||
type: object
|
||||
type: object
|
||||
histograms:
|
||||
additionalProperties:
|
||||
description: HistogramMetric holds configuration of a single metric of type Histogram
|
||||
properties:
|
||||
buckets:
|
||||
items:
|
||||
description: A Number represents a JSON number literal.
|
||||
type: string
|
||||
type: array
|
||||
labels:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- labels
|
||||
type: object
|
||||
type: object
|
||||
required:
|
||||
- counters
|
||||
- gauges
|
||||
- histograms
|
||||
type: object
|
||||
minRunners:
|
||||
description: Required
|
||||
minimum: 0
|
||||
|
|
|
|||
|
|
@ -7772,6 +7772,55 @@ spec:
|
|||
maxRunners:
|
||||
minimum: 0
|
||||
type: integer
|
||||
metrics:
|
||||
description: MetricsConfig holds configuration parameters for each metric type
|
||||
properties:
|
||||
counters:
|
||||
additionalProperties:
|
||||
description: CounterMetric holds configuration of a single metric of type Counter
|
||||
properties:
|
||||
labels:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- labels
|
||||
type: object
|
||||
type: object
|
||||
gauges:
|
||||
additionalProperties:
|
||||
description: GaugeMetric holds configuration of a single metric of type Gauge
|
||||
properties:
|
||||
labels:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- labels
|
||||
type: object
|
||||
type: object
|
||||
histograms:
|
||||
additionalProperties:
|
||||
description: HistogramMetric holds configuration of a single metric of type Histogram
|
||||
properties:
|
||||
buckets:
|
||||
items:
|
||||
description: A Number represents a JSON number literal.
|
||||
type: string
|
||||
type: array
|
||||
labels:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- labels
|
||||
type: object
|
||||
type: object
|
||||
required:
|
||||
- counters
|
||||
- gauges
|
||||
- histograms
|
||||
type: object
|
||||
minRunners:
|
||||
minimum: 0
|
||||
type: integer
|
||||
|
|
|
|||
|
|
@ -119,6 +119,35 @@ githubConfigSecret:
|
|||
# - name: side-car
|
||||
# image: example-sidecar
|
||||
|
||||
listenerMetrics:
|
||||
counters:
|
||||
gha_started_jobs_total:
|
||||
labels: []
|
||||
gha_completed_jobs_total:
|
||||
labels: []
|
||||
gauges:
|
||||
gha_assigned_jobs:
|
||||
labels: []
|
||||
gha_running_jobs:
|
||||
labels: []
|
||||
gha_registered_runners:
|
||||
labels: []
|
||||
gha_busy_runners:
|
||||
labels: []
|
||||
gha_min_runners:
|
||||
labels: []
|
||||
gha_max_runners:
|
||||
labels: []
|
||||
gha_desired_runners:
|
||||
labels: []
|
||||
gha_idle_runners:
|
||||
labels: []
|
||||
histograms:
|
||||
gha_job_startup_duration_seconds:
|
||||
labels: []
|
||||
gha_job_execution_duration_seconds:
|
||||
labels: []
|
||||
|
||||
## template is the PodSpec for each runner Pod
|
||||
## For reference: https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec
|
||||
template:
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"net/url"
|
||||
"os"
|
||||
|
||||
"github.com/actions/actions-runner-controller/apis/actions.github.com/v1alpha1"
|
||||
"github.com/actions/actions-runner-controller/build"
|
||||
"github.com/actions/actions-runner-controller/github/actions"
|
||||
"github.com/actions/actions-runner-controller/logging"
|
||||
|
|
@ -16,22 +17,23 @@ import (
|
|||
)
|
||||
|
||||
type Config struct {
|
||||
ConfigureUrl string `json:"configure_url"`
|
||||
AppID int64 `json:"app_id"`
|
||||
AppInstallationID int64 `json:"app_installation_id"`
|
||||
AppPrivateKey string `json:"app_private_key"`
|
||||
Token string `json:"token"`
|
||||
EphemeralRunnerSetNamespace string `json:"ephemeral_runner_set_namespace"`
|
||||
EphemeralRunnerSetName string `json:"ephemeral_runner_set_name"`
|
||||
MaxRunners int `json:"max_runners"`
|
||||
MinRunners int `json:"min_runners"`
|
||||
RunnerScaleSetId int `json:"runner_scale_set_id"`
|
||||
RunnerScaleSetName string `json:"runner_scale_set_name"`
|
||||
ServerRootCA string `json:"server_root_ca"`
|
||||
LogLevel string `json:"log_level"`
|
||||
LogFormat string `json:"log_format"`
|
||||
MetricsAddr string `json:"metrics_addr"`
|
||||
MetricsEndpoint string `json:"metrics_endpoint"`
|
||||
ConfigureUrl string `json:"configure_url"`
|
||||
AppID int64 `json:"app_id"`
|
||||
AppInstallationID int64 `json:"app_installation_id"`
|
||||
AppPrivateKey string `json:"app_private_key"`
|
||||
Token string `json:"token"`
|
||||
EphemeralRunnerSetNamespace string `json:"ephemeral_runner_set_namespace"`
|
||||
EphemeralRunnerSetName string `json:"ephemeral_runner_set_name"`
|
||||
MaxRunners int `json:"max_runners"`
|
||||
MinRunners int `json:"min_runners"`
|
||||
RunnerScaleSetId int `json:"runner_scale_set_id"`
|
||||
RunnerScaleSetName string `json:"runner_scale_set_name"`
|
||||
ServerRootCA string `json:"server_root_ca"`
|
||||
LogLevel string `json:"log_level"`
|
||||
LogFormat string `json:"log_format"`
|
||||
MetricsAddr string `json:"metrics_addr"`
|
||||
MetricsEndpoint string `json:"metrics_endpoint"`
|
||||
Metrics map[string]*v1alpha1.MetricConfig `json:"metrics"`
|
||||
}
|
||||
|
||||
func Read(path string) (Config, error) {
|
||||
|
|
|
|||
|
|
@ -119,6 +119,55 @@ spec:
|
|||
description: Required
|
||||
minimum: 0
|
||||
type: integer
|
||||
metrics:
|
||||
description: MetricsConfig holds configuration parameters for each metric type
|
||||
properties:
|
||||
counters:
|
||||
additionalProperties:
|
||||
description: CounterMetric holds configuration of a single metric of type Counter
|
||||
properties:
|
||||
labels:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- labels
|
||||
type: object
|
||||
type: object
|
||||
gauges:
|
||||
additionalProperties:
|
||||
description: GaugeMetric holds configuration of a single metric of type Gauge
|
||||
properties:
|
||||
labels:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- labels
|
||||
type: object
|
||||
type: object
|
||||
histograms:
|
||||
additionalProperties:
|
||||
description: HistogramMetric holds configuration of a single metric of type Histogram
|
||||
properties:
|
||||
buckets:
|
||||
items:
|
||||
description: A Number represents a JSON number literal.
|
||||
type: string
|
||||
type: array
|
||||
labels:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- labels
|
||||
type: object
|
||||
type: object
|
||||
required:
|
||||
- counters
|
||||
- gauges
|
||||
- histograms
|
||||
type: object
|
||||
minRunners:
|
||||
description: Required
|
||||
minimum: 0
|
||||
|
|
|
|||
|
|
@ -7772,6 +7772,55 @@ spec:
|
|||
maxRunners:
|
||||
minimum: 0
|
||||
type: integer
|
||||
metrics:
|
||||
description: MetricsConfig holds configuration parameters for each metric type
|
||||
properties:
|
||||
counters:
|
||||
additionalProperties:
|
||||
description: CounterMetric holds configuration of a single metric of type Counter
|
||||
properties:
|
||||
labels:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- labels
|
||||
type: object
|
||||
type: object
|
||||
gauges:
|
||||
additionalProperties:
|
||||
description: GaugeMetric holds configuration of a single metric of type Gauge
|
||||
properties:
|
||||
labels:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- labels
|
||||
type: object
|
||||
type: object
|
||||
histograms:
|
||||
additionalProperties:
|
||||
description: HistogramMetric holds configuration of a single metric of type Histogram
|
||||
properties:
|
||||
buckets:
|
||||
items:
|
||||
description: A Number represents a JSON number literal.
|
||||
type: string
|
||||
type: array
|
||||
labels:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- labels
|
||||
type: object
|
||||
type: object
|
||||
required:
|
||||
- counters
|
||||
- gauges
|
||||
- histograms
|
||||
type: object
|
||||
minRunners:
|
||||
minimum: 0
|
||||
type: integer
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ func (b *ResourceBuilder) newAutoScalingListener(autoscalingRunnerSet *v1alpha1.
|
|||
ImagePullSecrets: imagePullSecrets,
|
||||
Proxy: autoscalingRunnerSet.Spec.Proxy,
|
||||
GitHubServerTLS: autoscalingRunnerSet.Spec.GitHubServerTLS,
|
||||
Metrics: autoscalingRunnerSet.Spec.ListenerMetrics,
|
||||
Template: autoscalingRunnerSet.Spec.ListenerTemplate,
|
||||
},
|
||||
}
|
||||
|
|
@ -198,6 +199,7 @@ func (b *ResourceBuilder) newScaleSetListenerConfig(autoscalingListener *v1alpha
|
|||
LogFormat: scaleSetListenerLogFormat,
|
||||
MetricsAddr: metricsAddr,
|
||||
MetricsEndpoint: metricsEndpoint,
|
||||
Metrics: autoscalingListener.Spec.Metrics,
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
|
|
|||
Loading…
Reference in New Issue