How to include curly braces in a string?

  • What are you trying to achieve?
    I am trying to query a path that has curly braces {} in the url.

http_server_handling_seconds_count{environment=“$environment”, mode=“$mode”, method=“POST” , status_code=“200", path=“xxx/xxx/{}/xxx/x{}/xxx”}

  • What happened?
    The problem is that the {} in the string escape the string sequence so therefore I cannot include it in the path value. Is there any way I can include the ‘{}’ in the actual string that I am trying to pass to the path?

Welcome @nishi85
Maybe this?

http_server_handling_seconds_count{environment="$environment", mode="$mode", method="POST", status_code="200", path="xxx/xxx/\\{\\}/xxx/x\\{\\}/xxx"}

This should allow the curly braces to be treated as literal characters in the path value rather than being interpreted as a part of the PromQL syntax.

Thank you so much for your reply. Sadly, the closing ‘}’ always ends the string no matter how many escape characters I tried.

Here is a better representation of what I am trying to treat as literal characters. I am also doing this query in chronosphere. I dont know if that makes a difference.

“xxx/x{xxx}/xxx/{xxx}/xxx/xxx/xxx”