1

when I pass the parameters from a sh to my server prometheus shows the error, the data I get from a json

my sh

#!/bin/bash
REPORT=C:/gauge2/gauge/reports/json-report
FILE=$REPORT/result.json     

# Validate & push the metrics
if [ -f $FILE ]; then
   echo "File $FILE exists."
   cat $REPORT/result.json | \
    # Extract a nice json from last report
    jq -r '.projectName as $project |.environment as $env | .specResults[] |"ngt_lambda_qa {env=\"\($env)\", spec=\"\(.specHeading|gsub("\"";"\\\""))\", result=\"\(.executionStatus)\"} \(.executionTime)"' | \

    # Send to the metric server
    curl -v --data-binary @- localhost:9091/metrics/job/prometheus
    name=`uname -n`
    timestamp=`date +%s`
    result=`jq -r '.executionStatus' $REPORT/result.json`
    echo "prometrics_exec{name=\"$name\", result=\"$result\"} $timestamp" | curl --data-binary @- localhost:9091/metrics/prueba
else
   echo "File $FILE does not exist."
fi
sleep 90
cristianccrj
  • 21
  • 1
  • 5

1 Answers1

0

Your data looks like it has a carriage return (the '/r') character at the end of the line. jq is expecting a float value, which the parsed value is not, as it has this character added.

Difference between \n and \r?

Hexdump
  • 1
  • 3