Started implementing configurable metrics model
This commit is contained in:
		
							parent
							
								
									fb9b96bf75
								
							
						
					
					
						commit
						dbac795ab0
					
				|  | @ -61,6 +61,9 @@ type AutoscalingListenerSpec struct { | ||||||
| 	// +optional
 | 	// +optional
 | ||||||
| 	GitHubServerTLS *GitHubServerTLSConfig `json:"githubServerTLS,omitempty"` | 	GitHubServerTLS *GitHubServerTLSConfig `json:"githubServerTLS,omitempty"` | ||||||
| 
 | 
 | ||||||
|  | 	// +optional
 | ||||||
|  | 	Metrics *MetricsConfig `json:"metrics,omitempty"` | ||||||
|  | 
 | ||||||
| 	// +optional
 | 	// +optional
 | ||||||
| 	Template *corev1.PodTemplateSpec `json:"template,omitempty"` | 	Template *corev1.PodTemplateSpec `json:"template,omitempty"` | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -18,6 +18,7 @@ package v1alpha1 | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"crypto/x509" | 	"crypto/x509" | ||||||
|  | 	"encoding/json" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"net/url" | 	"net/url" | ||||||
|  | @ -74,6 +75,9 @@ type AutoscalingRunnerSetSpec struct { | ||||||
| 	// Required
 | 	// Required
 | ||||||
| 	Template corev1.PodTemplateSpec `json:"template,omitempty"` | 	Template corev1.PodTemplateSpec `json:"template,omitempty"` | ||||||
| 
 | 
 | ||||||
|  | 	// +optional
 | ||||||
|  | 	ListenerMetrics *MetricsConfig `json:"metrics,omitempty"` | ||||||
|  | 
 | ||||||
| 	// +optional
 | 	// +optional
 | ||||||
| 	ListenerTemplate *corev1.PodTemplateSpec `json:"listenerTemplate,omitempty"` | 	ListenerTemplate *corev1.PodTemplateSpec `json:"listenerTemplate,omitempty"` | ||||||
| 
 | 
 | ||||||
|  | @ -232,6 +236,29 @@ type ProxyServerConfig struct { | ||||||
| 	CredentialSecretRef string `json:"credentialSecretRef,omitempty"` | 	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
 | // AutoscalingRunnerSetStatus defines the observed state of AutoscalingRunnerSet
 | ||||||
| type AutoscalingRunnerSetStatus struct { | type AutoscalingRunnerSetStatus struct { | ||||||
| 	// +optional
 | 	// +optional
 | ||||||
|  |  | ||||||
|  | @ -119,6 +119,55 @@ spec: | ||||||
|                   description: Required |                   description: Required | ||||||
|                   minimum: 0 |                   minimum: 0 | ||||||
|                   type: integer |                   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: |                 minRunners: | ||||||
|                   description: Required |                   description: Required | ||||||
|                   minimum: 0 |                   minimum: 0 | ||||||
|  |  | ||||||
|  | @ -7772,6 +7772,55 @@ spec: | ||||||
|                 maxRunners: |                 maxRunners: | ||||||
|                   minimum: 0 |                   minimum: 0 | ||||||
|                   type: integer |                   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: |                 minRunners: | ||||||
|                   minimum: 0 |                   minimum: 0 | ||||||
|                   type: integer |                   type: integer | ||||||
|  |  | ||||||
|  | @ -119,6 +119,35 @@ githubConfigSecret: | ||||||
| #     - name: side-car | #     - name: side-car | ||||||
| #       image: example-sidecar | #       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 | ## template is the PodSpec for each runner Pod | ||||||
| ## For reference: https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec | ## For reference: https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec | ||||||
| template: | template: | ||||||
|  |  | ||||||
|  | @ -8,6 +8,7 @@ import ( | ||||||
| 	"net/url" | 	"net/url" | ||||||
| 	"os" | 	"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/build" | ||||||
| 	"github.com/actions/actions-runner-controller/github/actions" | 	"github.com/actions/actions-runner-controller/github/actions" | ||||||
| 	"github.com/actions/actions-runner-controller/logging" | 	"github.com/actions/actions-runner-controller/logging" | ||||||
|  | @ -32,6 +33,7 @@ type Config struct { | ||||||
| 	LogFormat                   string                            `json:"log_format"` | 	LogFormat                   string                            `json:"log_format"` | ||||||
| 	MetricsAddr                 string                            `json:"metrics_addr"` | 	MetricsAddr                 string                            `json:"metrics_addr"` | ||||||
| 	MetricsEndpoint             string                            `json:"metrics_endpoint"` | 	MetricsEndpoint             string                            `json:"metrics_endpoint"` | ||||||
|  | 	Metrics                     map[string]*v1alpha1.MetricConfig `json:"metrics"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func Read(path string) (Config, error) { | func Read(path string) (Config, error) { | ||||||
|  |  | ||||||
|  | @ -119,6 +119,55 @@ spec: | ||||||
|                   description: Required |                   description: Required | ||||||
|                   minimum: 0 |                   minimum: 0 | ||||||
|                   type: integer |                   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: |                 minRunners: | ||||||
|                   description: Required |                   description: Required | ||||||
|                   minimum: 0 |                   minimum: 0 | ||||||
|  |  | ||||||
|  | @ -7772,6 +7772,55 @@ spec: | ||||||
|                 maxRunners: |                 maxRunners: | ||||||
|                   minimum: 0 |                   minimum: 0 | ||||||
|                   type: integer |                   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: |                 minRunners: | ||||||
|                   minimum: 0 |                   minimum: 0 | ||||||
|                   type: integer |                   type: integer | ||||||
|  |  | ||||||
|  | @ -125,6 +125,7 @@ func (b *ResourceBuilder) newAutoScalingListener(autoscalingRunnerSet *v1alpha1. | ||||||
| 			ImagePullSecrets:              imagePullSecrets, | 			ImagePullSecrets:              imagePullSecrets, | ||||||
| 			Proxy:                         autoscalingRunnerSet.Spec.Proxy, | 			Proxy:                         autoscalingRunnerSet.Spec.Proxy, | ||||||
| 			GitHubServerTLS:               autoscalingRunnerSet.Spec.GitHubServerTLS, | 			GitHubServerTLS:               autoscalingRunnerSet.Spec.GitHubServerTLS, | ||||||
|  | 			Metrics:                       autoscalingRunnerSet.Spec.ListenerMetrics, | ||||||
| 			Template:                      autoscalingRunnerSet.Spec.ListenerTemplate, | 			Template:                      autoscalingRunnerSet.Spec.ListenerTemplate, | ||||||
| 		}, | 		}, | ||||||
| 	} | 	} | ||||||
|  | @ -198,6 +199,7 @@ func (b *ResourceBuilder) newScaleSetListenerConfig(autoscalingListener *v1alpha | ||||||
| 		LogFormat:                   scaleSetListenerLogFormat, | 		LogFormat:                   scaleSetListenerLogFormat, | ||||||
| 		MetricsAddr:                 metricsAddr, | 		MetricsAddr:                 metricsAddr, | ||||||
| 		MetricsEndpoint:             metricsEndpoint, | 		MetricsEndpoint:             metricsEndpoint, | ||||||
|  | 		Metrics:                     autoscalingListener.Spec.Metrics, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	var buf bytes.Buffer | 	var buf bytes.Buffer | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue