Ad Widget

Collapse

Discussion thread for official Zabbix Template HAProxy

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AlexL
    Zabbix Certified Specialist
    Zabbix Certified Specialist
    • Aug 2019
    • 55

    #1

    Discussion thread for official Zabbix Template HAProxy

    This thread is designed to provide grounds for discussion of the official Zabbix Template for HAProxy.
    The template and details of the template are available in GIT repository.
    HAProxy Agent
    https://git.zabbix.com/projects/ZBX/.../haproxy_agent
    HAProxy HTTP https://git.zabbix.com/projects/ZBX/...p/haproxy_http
    Zabbix is always looking for ways to improve our services and to make our users happier.
    We pride ourselves on doing our best each and every day, but we know that there is always something more to learn.
    We would like to hear back from you to know what have you liked and what would you improve in the template.

  • rstumbaum
    Junior Member
    • Jan 2020
    • 3

    #2
    Hi,

    and thanks for providing this official HAProxy template!

    My use case:
    I have some haproxy services running on active-passive heartbeat loadbalancers.

    When using the haproxy_agent version I get the problem that the inactive host is complaining that the HAProxy service is not running - since it gets started only on failover by heartbeat.

    When using the haproxy_http on the virtual IP I get the problem that I have to maintain for each Virtual-IP Host entry in Zabbix the {$HAPROXY.STATS.HOST} macro.


    Suggestion:
    Could you replace the {$HAPROXY.STATS.HOST} in the item configurations to {HOST.CONN} instead as it is in the haproxy_agent version?

    Best regards and a Happy New Year!
    Rainer

    Comment

    • max.ch.88
      Senior Member
      • Oct 2018
      • 206

      #3
      Originally posted by rstumbaum
      Hi,

      Suggestion:
      Could you replace the {$HAPROXY.STATS.HOST} in the item configurations to {HOST.CONN} instead as it is in the haproxy_agent version?
      https://git.zabbix.com/projects/ZBX/...Frelease%2F4.4
      The template is using {HOST.CONN} now.

      Comment

      • rstumbaum
        Junior Member
        • Jan 2020
        • 3

        #4
        There are two templates: agent based and http based. I have been writing about the http based one - you looked at the agent based one, where it is correct.

        It should be fixed here: https://git.zabbix.com/projects/ZBX/...Frelease%2F4.4

        Comment

        • max.ch.88
          Senior Member
          • Oct 2018
          • 206

          #5
          Both templates have the same triggers. And the "HAProxy service is not running" trigger will be lit even if you change {$HAPROXY.STATS.HOST} to {HOST.CONN}.
          Is it a big problem to maintain macro?
          An agentless template can be attached to a host with the agent checks and this will cause data collection to fail.
          You could make a copy of the template and change it as you need or create ZBX, if you think this is a mistake.

          Comment

          • rstumbaum
            Junior Member
            • Jan 2020
            • 3

            #6
            I did create a haproxy template by myself in 2011 using version 1.8. So yes, I do know my way around and am capable of things like that.

            But this is not the point. With every upgrade I try to move previously taken workarounds back into the standard (e.g. used zapcat and it took a while to switch to the jmx agent). Since the standard now provides maintained templates I try again to reduce my own maintenance efforts.

            When having a few active-passive haproxies it is inconvenient and failure-prone to set the macro value on a per virtual-ip host entry basis. But you would not assign the agent based template to the underlying machines of the cluster. So from my point of view the argument with the trigger duplication is not valid.

            I just wanted to give a feedback to improve the haproxy_http template for everybody.

            Comment

            • eki
              Junior Member
              • Feb 2020
              • 3

              #7
              Hi,

              is this template works under zabbix version 4.0.3?

              Best regards

              Comment

              • interestingusername
                Junior Member
                • Feb 2020
                • 2

                #8
                Just in-case anyone trips up like i did;

                If you don't perform SSL/TLS termination, the template wont work

                Comment

                • interestingusername
                  Junior Member
                  • Feb 2020
                  • 2

                  #9
                  Okay, on further investigation, it still doesn't work with the majority of stats even when in HTTP mode (like 2xx, 3xx codes)

                  Also it seems an error to only check 2xx & 3xx for front ends and not back ends (if you host multiple domains, you can only bind :443 to one front end and have to check for different domains)

                  On even more investigation;

                  The version template regex is wrong for Ubuntu, you can fix this by changing the template around line 145:

                  Code:
                  <params>try {
                      return value.match(/HAProxy version (\d+\.\d+\.\d+)/)[1];
                  }
                  catch (error) {
                      throw "HAProxy version is not found : " + error;
                  }</params>
                  The code for the JSON path for Nxxx doesn't seem to work, taking this JSON (taken from haproxy csv, coverted to json, shorted for post length);
                  Code:
                  [
                    {
                      "pxname": "https-in",
                      "svname": "FRONTEND",
                      "hrsp_1xx": 0,
                      "hrsp_2xx": 263,
                      "hrsp_3xx": 406,
                      "hrsp_4xx": 2,
                      "hrsp_5xx": 16
                    }
                  ]
                  With the following path
                  Code:
                  $.[?(@.pxname == 'https-in' && @.svname == 'FRONTEND')].hrsp_2xx
                  it;

                  Works here: http://jsonpath.herokuapp.com/

                  Doesn't work here: https://jsonpath.curiousconcept.com/

                  I cant seem to find anything about which implementation Zabbix use's but it doesn't seem to work ?

                  Updating the template to
                  Code:
                  $.[?(@.pxname == '{#PXNAME}')].hrsp_2xx.first()
                  doesnt fix it either

                  Comment

                  • max.ch.88
                    Senior Member
                    • Oct 2018
                    • 206

                    #10
                    Originally posted by interestingusername
                    Okay, on further investigation, it still doesn't work with the majority of stats even when in HTTP mode (like 2xx, 3xx codes)

                    ...
                    What is the Zabbix, OS and HAProxy version you are using?

                    Comment


                    • interestingusername
                      interestingusername commented
                      Editing a comment
                      zabbix 4.4 on ubuntu 18.04.4

                      HAProxy version 1.8.8-1ubuntu0.9, released 2019/12/02 on Ubuntu 18.04.1
                  • unficyp
                    Junior Member
                    • Dec 2014
                    • 27

                    #11
                    How can i get the agent based haproxy version to connect to 127.0.0.1:8404 and not to the ip of the server ? i don't want my stats page to be bound to the ip of the host.
                    thanks

                    Comment

                    • max.ch.88
                      Senior Member
                      • Oct 2018
                      • 206

                      #12
                      Originally posted by unficyp
                      How can i get the agent based haproxy version to connect to 127.0.0.1:8404 and not to the ip of the server ? i don't want my stats page to be bound to the ip of the host.
                      thanks
                      You could change {HOST.CONN} to 127.0.0.1 in the item keys.

                      Comment

                      • max.ch.88
                        Senior Member
                        • Oct 2018
                        • 206

                        #13
                        Originally posted by rstumbaum
                        Hi,

                        My use case:
                        I have some haproxy services running on active-passive heartbeat loadbalancers.

                        When using the haproxy_agent version I get the problem that the inactive host is complaining that the HAProxy service is not running - since it gets started only on failover by heartbeat.
                        I would suggest using a service like keepalived to have virtual IP and automatic redirection in failover case of active haproxy..

                        Originally posted by rstumbaum
                        Suggestion:
                        Could you replace the {$HAPROXY.STATS.HOST} in the item configurations to {HOST.CONN} instead as it is in the haproxy_agent version?
                        The template has been changed. The link on the file you could find in the header of the topic.

                        Comment

                        • max.ch.88
                          Senior Member
                          • Oct 2018
                          • 206

                          #14
                          Originally posted by interestingusername
                          Just in-case anyone trips up like i did;

                          If you don't perform SSL/TLS termination, the template wont work
                          Could you show or share your HAProxy configuration so we could make a working template?

                          Comment

                          • metal
                            Member
                            • Nov 2019
                            • 42

                            #15
                            I am using Zabbix 4.4.8

                            Any idea why backend(s) session information is not available in the template HAProxy, for example:
                            Session rate(Current|Max)
                            Sessions (Current|Max|Total|LbTot|Last)
                            Bytes (In|Out)

                            Click image for larger version

Name:	HA.png
Views:	2355
Size:	12.8 KB
ID:	401039

                            It is essential to have these metrics for backend(s).

                            These are available for frontend, but not backend, any idea how I can add these items to "(TCP) backend discovery"

                            thanks
                            Last edited by metal; 13-05-2020, 05:45.

                            Comment

                            Working...