Forum Discussion

Skeer's avatar
Skeer
Icon for Neophyte rankNeophyte
4 years ago

Monitoring HAProxy?

I've got a trio of Load Balancers running HAProxy that I need to monitor, and I found the HAProxy module and installed it. I verified using the 'Test Applies To' and it found all 3 servers, so I assume that means it's been associated right?  It's been a few days and the resources are not displaying any HAP related info nor do I have a dropdown (IDK the correct term) under the resource itself like there is for CPU, Disks, etc.

Second question.. reading the description here: https://www.logicmonitor.com/integrations/ha-proxy am I correct in assuming that the only stats this module will report is sessions?  If so that's missing a ton of important stats....

 

Thanks!!

  • Stuart do yo happen to have a CSV version of this Datasource?

  • Anonymous's avatar
    Anonymous

    Ok, i think i have something for you. Using this haproxy.cfg file:

    frontend stats
        bind :8404
        mode            http
        log             global
        maxconn 10
    
        timeout client  100s
        timeout server  100s
        timeout connect 100s
        timeout queue   100s
    
        stats enable
        stats hide-version
        stats refresh 30s
        stats show-node
        stats uri  /haproxy?stats
    
    frontend mysite
    frontend hissite
    frontend theothersite
    frontend google.com
    

     

    I was able to write a DS to pull in 56 different datapoints for each frontend. Your mileage may vary. My /haproxy?stats is running on port 80, not 8404 (running inside a container where the container runtime remaps from 80:8404. Either way, you can add a property to the host called "haproxy.port" to specify a port other than 80 that your stats page is running on. I'll be publishing this to the Exchange shortly where it will need to undergo code review, but here it is in the meantime: https://github.com/sweenig/lmcommunity/tree/master/haproxy_2_4

    FYI, instead of scraping the HTML like the old version did, i dove into the json version of the data. I don't know if this just wasn't available in previous versions of HAProxy, or if someone thought it was easier to scrape the HTML. Either way, it necessitates a new DS since the collection method changes from WEBPAGE to BATCHSCRIPT. You should be able to import it into your portal without changing the existing HAProxy DS. Once you get it working, you can delete the existing HAProxy DS.

  • Anonymous's avatar
    Anonymous

    Yes, the only datapoint that DataSource tracks is sessions. It would seem the active discovery is not returning anything in your case. Navigate to the DataSource (the same place you tested the AppliesTo) and click the "Test Active Discovery" button. If you see no results there, that's your problem. 

    This DS uses the HTTP discovery method, meaning that discovery involves pulling up a web page and scraping it for the instances (that's the word you were looking for). In this case, it's looking at https://[hostname/ip]/haproxy?stats and scrapes looking for anything matching RegEx: <th colspan=2 class=.pxname.>(.*?)</th>. I would start by hitting one of your stats enabled frontend on one of the haproxies to see if the page loads. If it does not, you probably need to add that frontend to your haproxy config.

    It's possible that this used to be enabled out of the box for older versions of haproxy and the newest version of haproxy requires you to explicitly configure it.

    Once you get the page loading in your browser, you might need to make some changes to the DS to get the discovery to pull the page correctly. Once that's working, it looks like it shouldn't be hard to get the other stats from the table on that page. You'll just have to get real familiar with RegEx.

    I just got haproxy up and running in Docker and i'll take a look today during any free time i have to see what can be done to pull some of the other stats. Did you manually add the haproxy category to your servers or was it discovered? I'm not aware of a propertysource that auto-discovers haproxy installed on devices, but it wouldn't be the first time there's a propertysource i'm unaware of.