Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACM-14962: init MCOA metrics #1659

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ type PlatformLogsCollectionSpec struct {
Enabled bool `json:"enabled,omitempty"`
}

// PlatformMetricsCollectionSpec defines the spec for the addon to collect and forward metrics
// from fleet managed clusters.
type PlatformMetricsCollectionSpec struct {
// Enabled defines a flag to enable/disable the platform metrics collection.
//
// +optional
// +kubebuilder:validation:Optional
Enabled bool `json:"enabled,omitempty"`
}
Comment on lines +71 to +79
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this initial version since metrics will be taking a managed approach to metric collection I wonder if these values are the best ones to use since the equivalent for logs & traces currently correlates to an unmanaged approach where the user fully controls the root resources. I would be in favor of deliberating a bit how we want these different scenarios to be exposed to users. This correlates with stolostron/multicluster-observability-addon#88 (comment) maybe a discussion for the nexus syncs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean that you expect different fields in the MCO CRD to have either managed or unmanaged deployments?
It would be very interesting to discuss those concepts in the next nexus sync.
On the metrics side, I am not sure there is demand for unmanaged type of deployments 🤷 . The expressed need is to replicate what we have now. We need something in between with some managed fields and some that we can leave it to the user for fine tuning.
Let's discuss all that in the nexus sync 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% let's discuss on nexus sync 👍 just writing these down so we can go back to them:

  • if a signal is providing a turnkey solution then it will most likely be managed since that's the only way to reasonably offer support the storage side
  • maybe some use-cases only make sense to be managed (storage for instance, if you enable storage you are opting into the managed use case)
  • otherwise if we want to provide the unmanaged use-case for storage then we have to think how will it look like on the MCO CR
  • whatever we decide we should make sure that the CR feels similar across signals


// PlatformLogsSpec defines the spec for the addon to collect, forward and store logs
// from fleet managed clusters.
type PlatformLogsSpec struct {
Expand All @@ -79,6 +89,17 @@ type PlatformLogsSpec struct {
Collection PlatformLogsCollectionSpec `json:"collection,omitempty"`
}

// PlatformMetricsSpec defines the spec for the addon to collect, forward and store metrics
// from fleet managed clusters.
type PlatformMetricsSpec struct {
// Collection defines the spec for the addon to collect and forward metrics
// from fleet managed clusters.
//
// +optional
// +kubebuilder:validation:Optional
Collection PlatformMetricsCollectionSpec `json:"collection,omitempty"`
}

// PlatformCapabilitiesSpec defines the observability capabilities managed by the addon
// for platform components.
type PlatformCapabilitiesSpec struct {
Expand All @@ -88,6 +109,13 @@ type PlatformCapabilitiesSpec struct {
// +optional
// +kubebuilder:validation:Optional
Logs PlatformLogsSpec `json:"logs,omitempty"`

// Metrics defines the configuration spec for collecting and storing metrics from
// platform components running on fleet managed clusters.
//
// +optional
// +kubebuilder:validation:Optional
Metrics PlatformMetricsSpec `json:"metrics,omitempty"`
}

// ClusterLogForwarderSpec defines the spec for the addon to collect and forward logs
Expand All @@ -110,6 +138,16 @@ type UserWorkloadLogsCollectionSpec struct {
ClusterLogForwarder ClusterLogForwarderSpec `json:"clusterLogForwarder,omitempty"`
}

// UserWorkloadLogsSpec defines the spec for the addon to collect,forward and store logs
// from user workloads hosted on fleet managed clusters.
type UserWorkloadMetricsCollectionSpec struct {
// Enabled defines a flag to enable/disable the platform metrics collection.
//
// +optional
// +kubebuilder:validation:Optional
Enabled bool `json:"enabled,omitempty"`
}

// UserWorkloadLogsSpec defines the spec for the addon to collect,forward and store logs
// from user workloads hosted on fleet managed clusters.
type UserWorkloadLogsSpec struct {
Expand All @@ -121,6 +159,17 @@ type UserWorkloadLogsSpec struct {
Collection UserWorkloadLogsCollectionSpec `json:"collection,omitempty"`
}

// UserWorkloadMetricsSpec defines the spec for the addon to collect, forward and store metrics
// from user workloads hosted on fleet managed clusters.
type UserWorkloadMetricsSpec struct {
// Collection defines the spec for the addon to collect and forward metrics
// from user workloads hosted on fleet managed clusters.
//
// +optional
// +kubebuilder:validation:Optional
Collection UserWorkloadMetricsCollectionSpec `json:"collection,omitempty"`
}

// OpenTelemetryCollectorSpec defines the spec for the addon to collect and forward observability signals
// using the OpenTelemetryCollector custom resource.
type OpenTelemetryCollectorSpec struct {
Expand Down Expand Up @@ -176,6 +225,14 @@ type UserWorkloadCapabilitiesSpec struct {
// +optional
// +kubebuilder:validation:Optional
Logs UserWorkloadLogsSpec `json:"logs,omitempty"`

// Metrics defines the spec for the addon to collect, forward and store metrics
// from user workloads hosted on fleet managed clusters.
//
// +optional
// +kubebuilder:validation:Optional
Metrics UserWorkloadMetricsSpec `json:"metrics,omitempty"`

// Traces defines the spec for the addon to collect, forward and store traces
// from user workloads hosted on fleet managed clusters.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ metadata:
}
]
capabilities: Basic Install
createdAt: "2024-09-23T12:07:01Z"
createdAt: "2024-11-06T16:52:14Z"
operators.operatorframework.io/builder: operator-sdk-v1.34.2
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
name: multicluster-observability-operator.v0.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10036,6 +10036,22 @@ spec:
type: boolean
type: object
type: object
metrics:
description: |-
Metrics defines the configuration spec for collecting and storing metrics from
platform components running on fleet managed clusters.
properties:
collection:
description: |-
Collection defines the spec for the addon to collect and forward metrics
from fleet managed clusters.
properties:
enabled:
description: Enabled defines a flag to enable/disable
the platform metrics collection.
type: boolean
type: object
type: object
type: object
userWorkloads:
description: |-
Expand Down Expand Up @@ -10066,6 +10082,22 @@ spec:
type: object
type: object
type: object
metrics:
description: |-
Metrics defines the spec for the addon to collect, forward and store metrics
from user workloads hosted on fleet managed clusters.
properties:
collection:
description: |-
Collection defines the spec for the addon to collect and forward metrics
from user workloads hosted on fleet managed clusters.
properties:
enabled:
description: Enabled defines a flag to enable/disable
the platform metrics collection.
type: boolean
type: object
type: object
traces:
description: |-
Traces defines the spec for the addon to collect, forward and store traces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10020,6 +10020,22 @@ spec:
type: boolean
type: object
type: object
metrics:
description: |-
Metrics defines the configuration spec for collecting and storing metrics from
platform components running on fleet managed clusters.
properties:
collection:
description: |-
Collection defines the spec for the addon to collect and forward metrics
from fleet managed clusters.
properties:
enabled:
description: Enabled defines a flag to enable/disable
the platform metrics collection.
type: boolean
type: object
type: object
type: object
userWorkloads:
description: |-
Expand Down Expand Up @@ -10050,6 +10066,22 @@ spec:
type: object
type: object
type: object
metrics:
description: |-
Metrics defines the spec for the addon to collect, forward and store metrics
from user workloads hosted on fleet managed clusters.
properties:
collection:
description: |-
Collection defines the spec for the addon to collect and forward metrics
from user workloads hosted on fleet managed clusters.
properties:
enabled:
description: Enabled defines a flag to enable/disable
the platform metrics collection.
type: boolean
type: object
type: object
traces:
description: |-
Traces defines the spec for the addon to collect, forward and store traces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import (
placementctrl "github.com/stolostron/multicluster-observability-operator/operators/multiclusterobservability/controllers/placementrule"
certctrl "github.com/stolostron/multicluster-observability-operator/operators/multiclusterobservability/pkg/certificates"
"github.com/stolostron/multicluster-observability-operator/operators/multiclusterobservability/pkg/config"
mcoconfig "github.com/stolostron/multicluster-observability-operator/operators/multiclusterobservability/pkg/config"
"github.com/stolostron/multicluster-observability-operator/operators/multiclusterobservability/pkg/rendering"
smctrl "github.com/stolostron/multicluster-observability-operator/operators/multiclusterobservability/pkg/servicemonitor"
"github.com/stolostron/multicluster-observability-operator/operators/multiclusterobservability/pkg/util"
Expand Down Expand Up @@ -266,10 +267,16 @@ func (r *MultiClusterObservabilityReconciler) Reconcile(ctx context.Context, req
}
disableMCOACMAORender := !apierrors.IsNotFound(err)

obsAPIURL, err := mcoconfig.GetObsAPIExternalURL(ctx, r.Client, mcoconfig.GetDefaultNamespace())
if err != nil {
return ctrl.Result{}, fmt.Errorf("failed to get the Observatorium API URL: %w", err)
}

// Build render options
rendererOptions := &rendering.RendererOptions{
MCOAOptions: rendering.MCOARendererOptions{
DisableCMAORender: disableMCOACMAORender,
DisableCMAORender: disableMCOACMAORender,
MetricsHubHostname: obsAPIURL.Host,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,16 @@ spec:
# Describes the default Instrumentation type applied to all managed clusters.
- group: opentelemetry.io
resource: instrumentations
# Metrics forwarding configuration types.
- group: monitoring.coreos.com
resource: prometheusagents
- group: monitoring.coreos.com
resource: scrapeconfigs
- group: monitoring.coreos.com
resource: prometheusrules
installStrategy:
type: Placements
placements:
- name: global
namespace: open-cluster-management-global-set
configs:
- group: observability.openshift.io
resource: clusterlogforwarders
name: instance
namespace: open-cluster-management-observability
- group: opentelemetry.io
resource: opentelemetrycollectors
name: instance
namespace: open-cluster-management-observability
- group: opentelemetry.io
resource: instrumentations
name: instance
namespace: open-cluster-management-observability
configs: []
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@
- apiGroups: ["opentelemetry.io"]
resources: ["opentelemetrycollectors", "instrumentations"]
verbs: ["get", "list", "watch"]
# Role for addon to perform prometheus specific actions
- apiGroups: ["monitoring.coreos.com"]
resources: ["prometheusagents", "scrapeconfigs", "prometheusrules"]
verbs: ["get", "list", "watch", "create", "update", "delete"]
2 changes: 2 additions & 0 deletions operators/multiclusterobservability/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,15 @@
ClusterLogForwarderCRDName = "clusterlogforwarders.observability.openshift.io"
OpenTelemetryCollectorCRDName = "opentelemetrycollectors.opentelemetry.io"
InstrumentationCRDName = "instrumentations.opentelemetry.io"
PrometheusAgentCRDName = "prometheusagents.monitoring.coreos.com"
)

var (
mcoaSupportedCRDs = map[string]string{
ClusterLogForwarderCRDName: "v1",
OpenTelemetryCollectorCRDName: "v1beta1",
InstrumentationCRDName: "v1alpha1",
PrometheusAgentCRDName: "v1alpha1",
}
)

Expand Down Expand Up @@ -584,7 +586,7 @@

// GetClusterID is used to get the cluster uid.
func GetClusterID(ocpClient ocpClientSet.Interface) (string, error) {
clusterVersion, err := ocpClient.ConfigV1().ClusterVersions().Get(context.TODO(), "version", v1.GetOptions{})

Check failure on line 589 in operators/multiclusterobservability/pkg/config/config.go

View workflow job for this annotation

GitHub Actions / Formatters + Linters (Static Analysis) for Go

ocpClient.ConfigV1().ClusterVersions undefined (type "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1".ConfigV1Interface has no field or method ClusterVersions)
if err != nil {
log.Error(err, "Failed to get clusterVersion")
return "", err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ func TestGetMCOASupportedCRDNames(t *testing.T) {
"clusterlogforwarders.observability.openshift.io",
"opentelemetrycollectors.opentelemetry.io",
"instrumentations.opentelemetry.io",
"prometheusagents.monitoring.coreos.com",
}

result := GetMCOASupportedCRDNames()
Expand Down
Loading
Loading