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

feat(operator): Provide default OTLP attribute configuration #14410

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

xperimental
Copy link
Collaborator

@xperimental xperimental commented Oct 7, 2024

What this PR does / why we need it:

The main purpose of this PR is to provide a default set of OTLP attributes that will be persisted when using LokiStack in openshift-logging tenancy mode.

This PR also changes the API for specifying an OTLP attribute configuration in LokiStack to make it easier to use.

Which issue(s) this PR fixes:

LOG-6147

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here

… openshift-logging tenancy

- Extend API for default OTLP label set
- Disable autodetection of service.name
- Update non-otlp config tests
- Simplify OTLP attribute configuration
- Remove validator code
- Content-assist for runtime config
- Add openshift-logging defaults
- Only add ignore_defaults to config if needed
- Use Loki default OTLP attributes when none are specified
Copy link
Collaborator

@periklis periklis left a comment

Choose a reason for hiding this comment

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

quick first pass, testing this right now on my cluster.

Question: How do we define the drop action?

operator/internal/manifests/config_otlp.go Outdated Show resolved Hide resolved
ResourceAttributes: []config.OTLPAttribute{
{
Action: config.OTLPAttributeActionStreamLabel,
Regex: "openshift\\.labels\\..+",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: What is considered an OpenShift Label here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think there are any of these labels at the moment. This might be an extension point. I meant to write a question about this in the data-model PR, but I forgot. The attribute configuration itself is from the data-model repository.

"github.com/grafana/loki/operator/internal/manifests/internal/config"
)

func defaultOpenShiftLoggingAttributes(disableRecommended bool) config.OTLPAttributeConfig {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we move this function to the openshift package please? This entire file mingles openshift-related with generic otlp handling. We use to have configure* function pattern to patch with mergo when an openshift mode is selected, else pass it through.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think mergo would overcomplicate things here, but I can move the OpenShift defaults to a separate package if we want that distinction.

Comment on lines 46 to 56
"k8s.cronjob.name",
"k8s.daemonset.name",
"k8s.deployment.name",
"k8s.job.name",
"k8s.replicaset.name",
"k8s.statefulset.name",
"process.command_line",
"process.executable.name",
"process.executable.path",
"process.pid",
"service.name",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest to move the following to stream labels:

"k8s.cronjob.name",
"k8s.daemonset.name",
"k8s.deployment.name",
"k8s.statefulset.name",
"service.name",

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think we have data for any of these attributes yet, but it might make sense in the long run... (this also needs an update to data-model if we do this)

Copy link
Collaborator

@JoaoBraveCoding JoaoBraveCoding left a comment

Choose a reason for hiding this comment

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

First pass without testing or looking at the test cases.

operator/apis/loki/v1/lokistack_types.go Outdated Show resolved Hide resolved
//
// This option is supposed to be combined with a custom label configuration customizing the labels for the specific
// usecase.
//
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we mention that some attributes will still be configured even if this is enabled?

operator/apis/loki/v1/lokistack_types.go Outdated Show resolved Hide resolved
// altogether.
// TenantOTLPSpec defines an OTLP attribute configuration specific to a tenant. It extends OTLPSpec.
type TenantOTLPSpec struct {
// When IgnoreGlobalStreamLabels is true, then this tenant will ignore the global stream label configuration.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// When IgnoreGlobalStreamLabels is true, then this tenant will ignore the global stream label configuration.
// When IgnoreGlobalStreamLabels is true, then this tenant will ignore the global stream labels configuration.

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: should we clarify here what happens if you have global stream labels defined and the users also defines them for a tenant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think the plural ("labels") is correct, because "configuration" already implies a plural and you don't "pluralize a plural"? I might be confusing this with German rules (or personal preference), though.


Regarding the other point: Valid point, this might need more thought... For example if we need to account for this in the deduplication as well.

operator/internal/manifests/config_otlp.go Show resolved Hide resolved
Copy link
Collaborator Author

@xperimental xperimental left a comment

Choose a reason for hiding this comment

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

Added the simple changes, but the comments about the "ignore defaults" made me check how this is actually used in Loki and it doesn't match my expectation. I think we need to decide whether we want a "ignore global attributes" setting and, if yes, implement it ourselves. Let's quickly discuss this in the daily. Implementation then probably on Monday.

// altogether.
// TenantOTLPSpec defines an OTLP attribute configuration specific to a tenant. It extends OTLPSpec.
type TenantOTLPSpec struct {
// When IgnoreGlobalStreamLabels is true, then this tenant will ignore the global stream label configuration.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think the plural ("labels") is correct, because "configuration" already implies a plural and you don't "pluralize a plural"? I might be confusing this with German rules (or personal preference), though.


Regarding the other point: Valid point, this might need more thought... For example if we need to account for this in the deduplication as well.

"github.com/grafana/loki/operator/internal/manifests/internal/config"
)

func defaultOpenShiftLoggingAttributes(disableRecommended bool) config.OTLPAttributeConfig {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think mergo would overcomplicate things here, but I can move the OpenShift defaults to a separate package if we want that distinction.

ResourceAttributes: []config.OTLPAttribute{
{
Action: config.OTLPAttributeActionStreamLabel,
Regex: "openshift\\.labels\\..+",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think there are any of these labels at the moment. This might be an extension point. I meant to write a question about this in the data-model PR, but I forgot. The attribute configuration itself is from the data-model repository.

Comment on lines 46 to 56
"k8s.cronjob.name",
"k8s.daemonset.name",
"k8s.deployment.name",
"k8s.job.name",
"k8s.replicaset.name",
"k8s.statefulset.name",
"process.command_line",
"process.executable.name",
"process.executable.path",
"process.pid",
"service.name",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think we have data for any of these attributes yet, but it might make sense in the long run... (this also needs an update to data-model if we do this)

operator/internal/manifests/config_otlp.go Show resolved Hide resolved
@xperimental
Copy link
Collaborator Author

Updated the PR to reflect some of the changes we discussed during the daily. The CRD already reflects the final view, but the "copy global to tenant configuration" part is still missing. The current version still provides defaults useful for testing with CLO, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants