# Use variables to define http-check parameters

**URL:** <https://discourse.haproxy.org/t/use-variables-to-define-http-check-parameters/7396>\
**Category:** Help!\
**Created:** [February 14, 2022, 11:01am UTC](https://discourse.haproxy.org/t/use-variables-to-define-http-check-parameters/7396 "2022-02-14T11:01:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stmx38](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/stmx38/32/1638_2.png) [@stmx38](https://discourse.haproxy.org/u/stmx38)\
**Post date:** [February 14, 2022, 11:01am UTC](https://discourse.haproxy.org/t/use-variables-to-define-http-check-parameters/7396/1 "2022-02-14T11:01:52Z")

</div>

Hello,

I just started to use HAProxy and trying to understand how to write config in more optimised way.

For example, we have 3 similar backends and they have some similar health checks:

> http-check send meth POST uri / hdr Content-Type application/json body “{"jsonrpc":"2.0","method":"eth\_syncing","params":,"id":1}”

It works fine when it is placed in such a way for every backend. As it is repeated more than one time, I’m trying to put it in the `global` section in a variable and then use just a variable in http-check.

```auto
global
  set-var-fmt proc.eth_sync "{\"jsonrpc\":\"2.0\",\"method\":\"eth_syncing\","params\":[],\"id\":1}"
  # set-var-fmt proc.eth_sync "{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}"

backend oe
  option httpchk
  http-check send meth POST uri / hdr Content-Type application/json body "%[var(proc.eth_sync)]"
  # http-check send meth POST uri / hdr Content-Type application/json body "%[var(proc.eth_sync),json]"

```

I also tried to use environment variables but got similar result - it doesn’t work.

1. Can such approach works or there is another way to do it?
2. Maybe there is a way to define independent http-check blocks and then just attach them per backend?

Thank you!
