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

[new_relic sink] unexpected backslash inserted before dot for attribute keys #15260

Closed
alfie029 opened this issue Nov 16, 2022 · 3 comments
Closed
Labels
provider: new relic Anything `new relic` service provider related sink: new_relic Anything `new_relic` sink related type: bug A code related bug.

Comments

@alfie029
Copy link

alfie029 commented Nov 16, 2022

A note for the community

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Problem

I used Vector.dev to forward my logs to NewRelic with newrelic sink, it worked well with the basic features, but not good if there are dots in attribute keys, for example, NewRelic log content have some specified attributes which keys are like entity.guid, entity.name, entity.type, trace.id, span.id and also my customized attribute key with same pattern (for example, given dotnet.nrerelic.logs.osversion ), all those key was changed with a backslash before dot, for example

dotnet\.newrelic\.logs\.osversion:"Unix 5.15.49.0"
entity\.name:"dotnet-newrelic-log-forward"
entity\.type:"SERVICE"

those messages would break the linking from logs to APM transactions

Here is a snapshot of newrelic logs query page
image

and the console output like below (use console sink)

{"@assembly":"dotnet-newrelic-log-forward, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","@l":"Information","@mt":"Content root path: {contentRoot}","@t":"2022-11-16T08:43:05.6213200Z","SourceContext":"Microsoft.Hosting.Lifetime","contentRoot":"/app/","dotnet.newrelic.logs.osversion":"Unix 5.15.49.0","entity.name":"dotnet-newrelic-log-forward","entity.type":"SERVICE","forward":"vector","hostname":"66eda19e2961","level":"Information","message":"Content root path: \"/app/\""}

Configuration

#                                    __   __  __
#                                    \ \ / / / /
#                                     \ V / / /
#                                      \_/  \/
#
#                                    V E C T O R
#                                   Configuration
#
# ------------------------------------------------------------------------------
# Website: https://vector.dev
# Docs: https://vector.dev/docs
# Chat: https://chat.vector.dev
# ------------------------------------------------------------------------------

# Change this to use a non-default directory for Vector data storage:
# data_dir = "/var/lib/vector"

[sources.dotnet]
  # REQUIRED - General
  type = "exec"
  command = ["dotnet", "/app/dotnet-newrelic-log-forward.dll"]
  mode = "streaming"

# See the Vector Remap Language reference for more info: https://vrl.dev
[transforms.parse_logs]
  # REQUIRED
  type = "remap"
  inputs = ["dotnet"]
  source = """
. = parse_json!(.message)
.forward = "vector" 
"""

# Print parsed logs to stdout
[sinks.newrelic]
  # REQUIRED
  type = "new_relic"
  inputs = [ "parse_logs" ]
  account_id = "${NEW_RELIC_ACCOUNT_ID}"
  license_key = "${NEW_RELIC_LICENSE_KEY}" # example, no default
  api = "logs"
  # OPTIONAL
  region = "us"
  
[sinks.console]
  type = "console"
  inputs = [ "parse_logs" ]
  target = "stdout"
  
  [sinks.console.encoding]
    codec = "json"

# Vector's GraphQL API (disabled by default)
# Uncomment to try it out with the `vector top` command or
# in your browser at http://localhost:8686
#[api]
#enabled = true
#address = "127.0.0.1:8686"

Version

vector 0.25.0 (x86_64-unknown-linux-gnu b573b51 2022-11-01)

Debug Output

No response

Example Data

{"@assembly":"dotnet-newrelic-log-forward, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","@l":"Information","@mt":"Content root path: {contentRoot}","@t":"2022-11-16T08:43:05.6213200Z","SourceContext":"Microsoft.Hosting.Lifetime","contentRoot":"/app/","dotnet.newrelic.logs.osversion":"Unix 5.15.49.0","entity.name":"dotnet-newrelic-log-forward","entity.type":"SERVICE","forward":"vector","hostname":"66eda19e2961","level":"Information","message":"Content root path: \"/app/\""}

Additional Context

No response

References

No response

@alfie029 alfie029 added the type: bug A code related bug. label Nov 16, 2022
@alfie029 alfie029 changed the title [newrelic sink] unexpected backslash inserted before dot for attribute keys [new_relic sink] unexpected backslash inserted before dot for attribute keys Nov 16, 2022
@jszwedko jszwedko added provider: new relic Anything `new relic` service provider related sink: new_relic Anything `new_relic` sink related labels Nov 28, 2022
@mayanksingh2298
Copy link

Hey is there any plan to sort this out?

@alfie029 I'm in a similar boat. As a workaround right now, I've been using http_sink insted of new relic sink with json encoding. Something like this:

new_relic_sink:
    type: http
    inputs:
      - ctrlb-newrelic-input
    uri: https://log-api.newrelic.com/log/v1
    buffer:
      max_events: 30000
      type: memory
    request:
      headers:
        X-License-Key : xxx
        Content-Type : application/json
    encoding:
      codec: json

Do you have a better solution?

@bruceg
Copy link
Member

bruceg commented Sep 13, 2024

This behavior actually changed in #21201, which went into versions 0.40.2 and 0.41.0. The current behavior no longer adds the \ escaping but rather ends up quoting dotted paths, which might not be the correct behavior neither.

Could you test with one of the above recent releases to see if the behavior is resolved for you?

@bruceg
Copy link
Member

bruceg commented Sep 18, 2024

This issue should be resolved in #21305. If you are still encountering problems, please open a new issue with the details.

@bruceg bruceg closed this as completed Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider: new relic Anything `new relic` service provider related sink: new_relic Anything `new_relic` sink related type: bug A code related bug.
Projects
None yet
Development

No branches or pull requests

4 participants