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

GCP logs exporter - resource fields mapping #26649

Closed
wgebis opened this issue Sep 12, 2023 · 6 comments · Fixed by #30929
Closed

GCP logs exporter - resource fields mapping #26649

wgebis opened this issue Sep 12, 2023 · 6 comments · Fixed by #30929
Assignees
Labels
documentation Improvements or additions to documentation exporter/googlecloud

Comments

@wgebis
Copy link

wgebis commented Sep 12, 2023

Component(s)

exporter/googlecloud

What happened?

Hi there!

I'm using GCP logs exported for pushing long to GCP from on-premiss VM isntances. Log entries in GCP has an empty section:

resource: {
labels: {
  location: "global"
  namespace: ""
  node_id: ""
  project_id: "example"
}
type: "generic_node"
}```

Is it possible to override fields like `namespace` or `node_id` with OPEL Collector configuration?

Best,
W


### Collector version

v0.82

### Environment information

## Environment
OS: MacOS
Compiler(if manually compiled): binary from dockerhub


### OpenTelemetry Collector configuration

```yaml
receivers:
  filelog:
    include:
      - /logs/logs/**/*.log
    start_at: beginning
    attributes:
      source: "example"
    operators:
      - type: regex_parser
        regex: '(?s)^(?P<time>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) \[(?P<millis>[^\]]+)\] \[(?P<sev>[^\]]+)\] \[(?P<logger>[^\]]+)\]\s?(?P<msg>.*)$'
        timestamp:
          parse_from: attributes.time
          layout: '%Y-%m-%d %H:%M:%S'
        severity:
          parse_from: attributes.sev
    multiline:
      line_start_pattern: '^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})'

exporters:
  googlecloud:
    log:
      default_log_name: "sample_log_name"

service:
  telemetry:
    logs:
      level: 'debug'
  pipelines:
    logs:
      receivers:
        - filelog
      exporters:
        - googlecloud

Log output

No response

Additional context

No response

@wgebis wgebis added bug Something isn't working needs triage New item requiring triage labels Sep 12, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@crobert-1
Copy link
Member

Hello @wgebis, I just have some questions help me better direct you here.

Your goal is to fill in the resource attributes namespace and node_id (and maybe more), is that correct?

Which environment (resource) are you trying to get the resource information (like namespace and node_id) from? Is it from the logs themselves, or are you trying to get these values from the environment that the collector is running in? Or would this be something else I missed?

@wgebis
Copy link
Author

wgebis commented Sep 15, 2023

Hi there!

Thanks for reply! I configure logging outside of GCP from external 3rd party k8s cluster. Finally I've figured it out by using resources attributes:

receivers:
  filelog/kit:
    resource:
      cloud.region: ${region}
      k8s.cluster.name: "name-k8s"
      k8s.namespace.name: ${namespace}
      k8s.container.name: ${deployment_name}
      k8s.pod.name: $${env:HOSTNAME}

Unfortunately I had to studied source code a bit: https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/82615d06c71484903ae6bfe917f87d66e76c00fe/internal/resourcemapping/resourcemapping.go#L191

Here is implementation of Google Cloud Exporter monitored resource mappings. It could be great to get it in README somewhere.

Thanks!

@dashpole dashpole self-assigned this Sep 15, 2023
@dashpole
Copy link
Contributor

Thanks for reporting @wgebis. I'll make sure this gets documentd

@dashpole dashpole added documentation Improvements or additions to documentation and removed needs triage New item requiring triage bug Something isn't working labels Sep 15, 2023
Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Nov 15, 2023
@crobert-1 crobert-1 removed the Stale label Nov 15, 2023
Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Jan 15, 2024
@crobert-1 crobert-1 removed the Stale label Jan 16, 2024
djaglowski pushed a commit that referenced this issue Feb 1, 2024
Fixes
#26649
Fixes
#27803

---------

Co-authored-by: Curtis Robert <crobert@splunk.com>
cparkins pushed a commit to AmadeusITGroup/opentelemetry-collector-contrib that referenced this issue Feb 1, 2024
Fixes
open-telemetry#26649
Fixes
open-telemetry#27803

---------

Co-authored-by: Curtis Robert <crobert@splunk.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation exporter/googlecloud
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants