Try changing "curl" to "echo" and you'll see the problem.
The problem is with your shell command. Anything inside single-quotes is not expanded - so $mydate remains as the literal string "$mydate" Use double-quotes - in which case you'll need to escape the double-quotes inside the double-quotes with backslash. Or use a real programming language. On Thursday, 2 September 2021 at 10:55:42 UTC+1 [email protected] wrote: > I am trying to use variables in "startsAt": and "endsAt ", but I get > the error parsing. > Moreover, if I substitute the output of variables, there are no errors. > $mydate1=` date -u +"%Y-%m-%dT%H:%M:%SZ" ` > $mydate2=` date -u +"%Y-%m-%dT%H:%M:%SZ" --date '4 hours' ` > > Example: > curl http://localhost:9093/api/v1/silences -d '{ > "matchers": [ > { > "name": "instance", > "value": "host1:9100", > "isRegex": true > } > ], > "startsAt": "$mydate1", > "endsAt": "$mydate2", > "createdBy": "api", > "comment": "Silence", > "status": { > "state": "active" > } > }' > -- You received this message because you are subscribed to the Google Groups "Prometheus Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/f4e4b977-621e-47be-bacf-cbff624d3857n%40googlegroups.com.

