mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] Add basic metrics for ArangoDeploymentReplication CR (GT-242) (#1402)
This commit is contained in:
parent
7def39ed6c
commit
6e2ff839c3
11 changed files with 237 additions and 2 deletions
|
@ -15,6 +15,7 @@
|
||||||
- (Bugfix) Fix GZIP encoding in case of small responses
|
- (Bugfix) Fix GZIP encoding in case of small responses
|
||||||
- (Bugfix) Fix PVC Rotation Discovery
|
- (Bugfix) Fix PVC Rotation Discovery
|
||||||
- (Feature) Allow to pass EphemeralStorage Resource to the Pods
|
- (Feature) Allow to pass EphemeralStorage Resource to the Pods
|
||||||
|
- (Feature) Add basic metrics for ArangoDeploymentReplication CR
|
||||||
|
|
||||||
## [1.2.32](https://github.com/arangodb/kube-arangodb/tree/1.2.32) (2023-08-07)
|
## [1.2.32](https://github.com/arangodb/kube-arangodb/tree/1.2.32) (2023-08-07)
|
||||||
- (Feature) Backup lifetime - remove Backup once its lifetime has been reached
|
- (Feature) Backup lifetime - remove Backup once its lifetime has been reached
|
||||||
|
|
|
@ -32,5 +32,7 @@
|
||||||
| [arangodb_operator_resources_arangodeployment_status_restores](./arangodb_operator_resources_arangodeployment_status_restores.md) | arangodb_operator | resources | Counter | Counter for deployment status restored |
|
| [arangodb_operator_resources_arangodeployment_status_restores](./arangodb_operator_resources_arangodeployment_status_restores.md) | arangodb_operator | resources | Counter | Counter for deployment status restored |
|
||||||
| [arangodb_operator_resources_arangodeployment_uptodate](./arangodb_operator_resources_arangodeployment_uptodate.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeployment is uptodate |
|
| [arangodb_operator_resources_arangodeployment_uptodate](./arangodb_operator_resources_arangodeployment_uptodate.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeployment is uptodate |
|
||||||
| [arangodb_operator_resources_arangodeployment_validation_errors](./arangodb_operator_resources_arangodeployment_validation_errors.md) | arangodb_operator | resources | Counter | Counter for deployment validation errors |
|
| [arangodb_operator_resources_arangodeployment_validation_errors](./arangodb_operator_resources_arangodeployment_validation_errors.md) | arangodb_operator | resources | Counter | Counter for deployment validation errors |
|
||||||
|
| [arangodb_operator_resources_arangodeploymentreplication_active](./arangodb_operator_resources_arangodeploymentreplication_active.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeploymentReplication is configured and running |
|
||||||
|
| [arangodb_operator_resources_arangodeploymentreplication_failed](./arangodb_operator_resources_arangodeploymentreplication_failed.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeploymentReplication is in Failed phase |
|
||||||
|
|
||||||
<!-- END(metricsTable) -->
|
<!-- END(metricsTable) -->
|
|
@ -0,0 +1,12 @@
|
||||||
|
# arangodb_operator_resources_arangodeploymentreplication_active (Gauge)
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Defines if ArangoDeploymentReplication is configured and running
|
||||||
|
|
||||||
|
## Labels
|
||||||
|
|
||||||
|
| Label | Description |
|
||||||
|
|:---------:|:--------------------------------|
|
||||||
|
| namespace | DeploymentReplication Namespace |
|
||||||
|
| name | DeploymentReplication Name |
|
|
@ -0,0 +1,12 @@
|
||||||
|
# arangodb_operator_resources_arangodeploymentreplication_failed (Gauge)
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Defines if ArangoDeploymentReplication is in Failed phase
|
||||||
|
|
||||||
|
## Labels
|
||||||
|
|
||||||
|
| Label | Description |
|
||||||
|
|:---------:|:--------------------------------|
|
||||||
|
| namespace | DeploymentReplication Namespace |
|
||||||
|
| name | DeploymentReplication Name |
|
|
@ -201,6 +201,24 @@ namespaces:
|
||||||
description: "Deployment Namespace"
|
description: "Deployment Namespace"
|
||||||
- key: name
|
- key: name
|
||||||
description: "Deployment Name"
|
description: "Deployment Name"
|
||||||
|
arangodeploymentreplication_active:
|
||||||
|
shortDescription: "Defines if ArangoDeploymentReplication is configured and running"
|
||||||
|
description: "Defines if ArangoDeploymentReplication is configured and running"
|
||||||
|
type: "Gauge"
|
||||||
|
labels:
|
||||||
|
- key: namespace
|
||||||
|
description: "DeploymentReplication Namespace"
|
||||||
|
- key: name
|
||||||
|
description: "DeploymentReplication Name"
|
||||||
|
arangodeploymentreplication_failed:
|
||||||
|
shortDescription: "Defines if ArangoDeploymentReplication is in Failed phase"
|
||||||
|
description: "Defines if ArangoDeploymentReplication is in Failed phase"
|
||||||
|
type: "Gauge"
|
||||||
|
labels:
|
||||||
|
- key: namespace
|
||||||
|
description: "DeploymentReplication Namespace"
|
||||||
|
- key: name
|
||||||
|
description: "DeploymentReplication Name"
|
||||||
members:
|
members:
|
||||||
unexpected_container_exit_codes:
|
unexpected_container_exit_codes:
|
||||||
shortDescription: "Counter of unexpected restarts in pod (Containers/InitContainers/EphemeralContainers)"
|
shortDescription: "Counter of unexpected restarts in pod (Containers/InitContainers/EphemeralContainers)"
|
||||||
|
|
39
pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_active.go
generated
Normal file
39
pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_active.go
generated
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package metric_descriptions
|
||||||
|
|
||||||
|
import "github.com/arangodb/kube-arangodb/pkg/util/metrics"
|
||||||
|
|
||||||
|
var (
|
||||||
|
arangodbOperatorResourcesArangodeploymentreplicationActive = metrics.NewDescription("arangodb_operator_resources_arangodeploymentreplication_active", "Defines if ArangoDeploymentReplication is configured and running", []string{`namespace`, `name`}, nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registerDescription(arangodbOperatorResourcesArangodeploymentreplicationActive)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ArangodbOperatorResourcesArangodeploymentreplicationActive() metrics.Description {
|
||||||
|
return arangodbOperatorResourcesArangodeploymentreplicationActive
|
||||||
|
}
|
||||||
|
|
||||||
|
func ArangodbOperatorResourcesArangodeploymentreplicationActiveGauge(value float64, namespace string, name string) metrics.Metric {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentreplicationActive().Gauge(value, namespace, name)
|
||||||
|
}
|
39
pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_failed.go
generated
Normal file
39
pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_failed.go
generated
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package metric_descriptions
|
||||||
|
|
||||||
|
import "github.com/arangodb/kube-arangodb/pkg/util/metrics"
|
||||||
|
|
||||||
|
var (
|
||||||
|
arangodbOperatorResourcesArangodeploymentreplicationFailed = metrics.NewDescription("arangodb_operator_resources_arangodeploymentreplication_failed", "Defines if ArangoDeploymentReplication is in Failed phase", []string{`namespace`, `name`}, nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registerDescription(arangodbOperatorResourcesArangodeploymentreplicationFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ArangodbOperatorResourcesArangodeploymentreplicationFailed() metrics.Description {
|
||||||
|
return arangodbOperatorResourcesArangodeploymentreplicationFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
func ArangodbOperatorResourcesArangodeploymentreplicationFailedGauge(value float64, namespace string, name string) metrics.Metric {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentreplicationFailed().Gauge(value, namespace, name)
|
||||||
|
}
|
|
@ -85,6 +85,7 @@ type DeploymentReplication struct {
|
||||||
status api.DeploymentReplicationStatus // Internal status of the CR
|
status api.DeploymentReplicationStatus // Internal status of the CR
|
||||||
config Config
|
config Config
|
||||||
deps Dependencies
|
deps Dependencies
|
||||||
|
metrics Metrics
|
||||||
|
|
||||||
eventCh chan *deploymentReplicationEvent
|
eventCh chan *deploymentReplicationEvent
|
||||||
stopCh chan struct{}
|
stopCh chan struct{}
|
||||||
|
@ -111,6 +112,8 @@ func New(config Config, deps Dependencies, apiObject *api.ArangoDeploymentReplic
|
||||||
|
|
||||||
dr.log = logger.WrapObj(dr)
|
dr.log = logger.WrapObj(dr)
|
||||||
|
|
||||||
|
localInventory.Add(dr)
|
||||||
|
|
||||||
go dr.run()
|
go dr.run()
|
||||||
|
|
||||||
return dr, nil
|
return dr, nil
|
||||||
|
@ -126,7 +129,7 @@ func (dr *DeploymentReplication) Update(apiObject *api.ArangoDeploymentReplicati
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the deployment replication.
|
// Delete the deployment replication.
|
||||||
// Called when the local storage was deleted by the user.
|
// Called when the CR was deleted by the user.
|
||||||
func (dr *DeploymentReplication) Delete() {
|
func (dr *DeploymentReplication) Delete() {
|
||||||
dr.log.Info("deployment replication is deleted by user")
|
dr.log.Info("deployment replication is deleted by user")
|
||||||
if atomic.CompareAndSwapInt32(&dr.stopped, 0, 1) {
|
if atomic.CompareAndSwapInt32(&dr.stopped, 0, 1) {
|
||||||
|
|
61
pkg/replication/inventory.go
Normal file
61
pkg/replication/inventory.go
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package replication
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/metrics/collector"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/metrics"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
localInventory = inventory{
|
||||||
|
deploymentReplications: map[string]map[string]*DeploymentReplication{},
|
||||||
|
}
|
||||||
|
collector.GetCollector().RegisterMetric(&localInventory)
|
||||||
|
}
|
||||||
|
|
||||||
|
var localInventory inventory
|
||||||
|
|
||||||
|
type inventory struct {
|
||||||
|
lock sync.Mutex
|
||||||
|
deploymentReplications map[string]map[string]*DeploymentReplication
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *inventory) CollectMetrics(in metrics.PushMetric) {
|
||||||
|
for _, drs := range i.deploymentReplications {
|
||||||
|
for _, dr := range drs {
|
||||||
|
dr.CollectMetrics(in)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *inventory) Add(dr *DeploymentReplication) {
|
||||||
|
i.lock.Lock()
|
||||||
|
defer i.lock.Unlock()
|
||||||
|
|
||||||
|
name, namespace := dr.apiObject.GetName(), dr.apiObject.GetNamespace()
|
||||||
|
if _, ok := i.deploymentReplications[namespace]; !ok {
|
||||||
|
i.deploymentReplications[namespace] = map[string]*DeploymentReplication{}
|
||||||
|
}
|
||||||
|
i.deploymentReplications[namespace][name] = dr
|
||||||
|
}
|
44
pkg/replication/metrics.go
Normal file
44
pkg/replication/metrics.go
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
//
|
||||||
|
|
||||||
|
package replication
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/generated/metric_descriptions"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/metrics"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Metrics struct {
|
||||||
|
DeploymentReplication struct {
|
||||||
|
Active, Failed bool
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dr *DeploymentReplication) CollectMetrics(m metrics.PushMetric) {
|
||||||
|
name, namespace := dr.apiObject.GetName(), dr.apiObject.GetNamespace()
|
||||||
|
|
||||||
|
m.Push(metric_descriptions.ArangodbOperatorResourcesArangodeploymentreplicationActiveGauge(
|
||||||
|
util.BoolSwitch[float64](dr.metrics.DeploymentReplication.Active, 1, 0), namespace, name),
|
||||||
|
)
|
||||||
|
m.Push(metric_descriptions.ArangodbOperatorResourcesArangodeploymentreplicationFailedGauge(
|
||||||
|
util.BoolSwitch[float64](dr.metrics.DeploymentReplication.Failed, 1, 0), namespace, name),
|
||||||
|
)
|
||||||
|
}
|
|
@ -50,8 +50,12 @@ func (dr *DeploymentReplication) inspectDeploymentReplication(lastInterval time.
|
||||||
dr.log.Err(err).Warn("Failed to add finalizers")
|
dr.log.Err(err).Warn("Failed to add finalizers")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isFailed := dr.status.Phase.IsFailed()
|
||||||
|
dr.metrics.DeploymentReplication.Failed = isFailed
|
||||||
|
dr.metrics.DeploymentReplication.Active = dr.status.Conditions.IsTrue(api.ConditionTypeConfigured)
|
||||||
|
|
||||||
// Is the deployment in failed state, if so, give up.
|
// Is the deployment in failed state, if so, give up.
|
||||||
if dr.status.Phase.IsFailed() {
|
if isFailed {
|
||||||
dr.log.Debug("Deployment replication is in Failed state.")
|
dr.log.Debug("Deployment replication is in Failed state.")
|
||||||
return nextInterval
|
return nextInterval
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue