Escaping characters in stage.json

Hello folks! I am stumped by what should have been a relatively simple issue. I have a log line in a json formatted log that I want to get rid of, that unfortunately has a . in it that makes the agent choke when it parses the config. The config in question is

stage.json {
    expressions = { "resources."process.executable.path"" = "" }
  }

the json key is process.executable.path and I thought that , given valid JMES double-quotting things should work but alas, no

Error: /usr/local/etc/grafana-agent-flow/config.river:76:33: expected =, got IDENT

I have also tried

stage.json {
    expressions = { "resources.\"process.executable.path\"" = "" }
  }

and that makes the JMES parser choke

Error: /usr/local/etc/grafana-agent-flow/config.river:74:1: Failed to build component: building component: invalid stage config could not compile JMES expression: SyntaxError: Unknown char: '\\'

Any suggestions on how I can get this working are very very welcome

Can you post rest of the process and scrape

1 Like
{
  "body": "sleeping for 4139",
  "severity": "INFO",
  "resources": {
    "deployment.environment": "remote",
    "host.arch": "x86_64",
    "os.description": "Mac OS X 14.1.2",
    "os.type": "darwin",
    "process.executable.path": "/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home/bin/java",
    "process.pid": 32460,
    "process.runtime.description": "Amazon.com Inc. OpenJDK 64-Bit Server VM 17.0.9+8-LTS",
    "process.runtime.name": "OpenJDK Runtime Environment",
    "process.runtime.version": "17.0.9+8-LTS",
    "service.name": "myappheavy",
    "service.namespace": "demo",
    "telemetry.auto.version": "1.28.0",
    "telemetry.sdk.language": "java",
    "telemetry.sdk.name": "opentelemetry",
    "telemetry.sdk.version": "1.28.0"
  },
  "instrumentation_scope": {
    "name": "test"
  }
}

Logs are not scraped, they are sent directly via logback/slf4j OTel integration to the agent

Can you post the rest of your config where…

stage.json {
    expressions = { "resources.\"process.executable.path\"" = "" }
  }```
Is used

have you tried… "process\.executable\.path" etc

Yup I have

Error: /usr/local/etc/grafana-agent-flow/config.river:76:30: unknown escape sequence

The whole process is as follows

loki.process "default" {
  stage.json {
    expressions = { "process\.executable\.path" = "" }
  }
  stage.replace {
    expression = ".*"
    source     = "process\.executable\.path"
    replace    = "removed"
  }
  forward_to = [
    module.git.grafana_cloud.exports.logs_receiver,
  ]
}