Skip to content

Metrics via exec on Linux #22655

Answered by abubakr-cgs
abubakr-cgs asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @pront , apologies for the late reply.
Using a double dollar sign is currently working good, according to this https://vector.dev/docs/reference/configuration/#escaping

Linux YAML

sources:
  memory_usage:
    type: "exec"
    mode: streaming
    command: ["sh", "-c", "free -m | awk 'NR==2{printf \"%s,%s,%s\", $$2, $$3, $$4}'"]

Result

{
  "command": [
    "sh",
    "-c",
    "free -m | awk 'NR==2{printf \"%s,%s,%s\", $2, $3, $4}'"
  ],
  "host": "DESKTOP-F1VAVE8",
  "message": "15866,10618,405",
  "pid": 3566328,
  "source_type": "exec",
  "stream": "stdout",
  "timestamp": "2025-04-09T05:26:34.569643376Z"
}

Thanks for your help!

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@abubakr-cgs
Comment options

Answer selected by abubakr-cgs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
source: exec Anything `exec` source related
2 participants