netscaler / netscaler-adc-metrics-exporter

Export metrics from Citrix ADC (NetScaler) to Prometheus
89 stars 33 forks source link

Enhancement: Extract and add label for ServiceGroup member name #29

Closed saruter closed 4 years ago

saruter commented 4 years ago

Describe the bug Not a bug, but an enhancement: Get all the servicegroupmember names of a servicegroup member and add that as label. You can get the members of a servicegroup with its members with the API-Request:

http://<netscaler-ip-address>/nitro/v1/stat/servicegroup/lbvip1?statbindings=yes

The servicegroupmembername is visible in the servicegroupname metric of the members:

{
    "errorcode": 0,
    "message": "Done",
    "severity": "NONE",
    "servicegroup": [
        {
            "servicegroupname": "lbvsg-SERVICEGROUP1-443",
            "state": "ENABLED",
            "servicetype": "SSL",
            "servicegroupmember": [
                {
                    "servicegroupname": "lbvsg-SERVICEGROUP1-443?SERVERNAME?443",
                    "port": 0,
                    "avgsvrttfb": "0",
                    "primaryipaddress": "10.x.y.z",
                    "primaryport": 443,
                    "servicetype": "SSL",
                    "state": "UP",
                    "totalrequests": "1960838",
                    "requestsrate": 0,
                    "totalresponses": "1960787",
                    "responsesrate": 0,
                    "totalrequestbytes": "1296529870",
                    "requestbytesrate": 89,
                    "totalresponsebytes": "3693259016",
                    "responsebytesrate": 109,
                    "curclntconnections": "0",
                    "surgecount": "0",
                    "cursrvrconnections": "0",
                    "svrestablishedconn": "0",
                    "curreusepool": "0",
                    "maxclients": "0",
                    "totsvrttlbtransactions": "0",
                    "toleratingttlbtransactions": "0",
                    "frustratingttlbtransactions": "0"
                },
                {
                ... other servicegroupmember stats
                }

Expected behavior For every member of a servicegroup it is possible to have the label with its member-name (the server name in Netscaler) for more descriptive metrics because "primaryipaddress" is not really "human-friendly" in dashboards. An example usage is the top10 list of members (with its names, not ip addresses) with the highest TTFB values.

aroraharsh23 commented 4 years ago

Hi @saruter, Thanks for new Enhancement suggestion. We'll review this and if suitable, will include in our next release.

aroraharsh23 commented 4 years ago

@saruter I reviewed this, there is an issue with this: With the API that you suggested, we do get "servicegroupname": "lbvsg-SERVICEGROUP1-443?SERVERNAME?443",

Issue is that, 'SERVERNAME' here can also be an IP address, as, giving a string name is not mandatory. So, if we extract SERVERNAME from here and add a new label, then, there can be conflict when it is not a name but an IP address. For instance a label like servername='1.1.1.1' won't look good. Though, i agree, if we give a name, then, it's fine. But we cannot generalise.

Other option is, we can give the entire name as member value, which here would be ""lbvsg-SERVICEGROUP1-443?SERVERNAME?443"" With all these "?", doesn't look great either. In case of IP address as server, it would look like "u'servicegroupname': u'k8s-apache-ingress_default_80_k8s-apache_default_80_svc?10.244.1.36?80'"

That's why "primaryipaddress" is used. Let me know if you have a different opinion.

saruter commented 4 years ago

@aroraharsh23 I agree on your point that a servername could also be an IP address, but I see no problem in a new label "citrixadc_servername" for example which is holding the exact value like in Netscaler GUI or config-file. If it's possible to enter an IP address in the "Name" Field in the GUI or per command line it could/should be represented as an field in the metrics.

The context help for the servername field in Netscaler GUI says:

Name for the server. Must begin with an ASCII alphabetic or underscore (_) character, and must contain only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at (@), equals (=), and hyphen (-) characters. Can be changed after the name is created.
This is a mandatory argument. 

So in my opinion a exact mapping of this value in a metrics field would be fine, regardless of being a string or ip-address. The other field "primaryipaddress"/"citrixadc_service_ip" should still be populated with the ip address of the servers.

I think that a lot of people are using the adc-metrics-exporter without using the adc-k8s-ingress part and therefore are configuring the servers on a netscaler in the classic way using names and not ip addresses.

I hope I could clarify my side and I'm really looking forward to see this feature being implemented :-)

aroraharsh23 commented 4 years ago

@saruter Thanks for input, Will try to include this soon. Will update the same.

cameronkerrnz commented 4 years ago

How much extra time does this add to the scrape-time? I'm just thinking of in order versions of Netscaler ADC it was much faster than now to display the SSL Certificates in the web UI; but in recent versions it seems to take much longer, and the web UI during this time says its getting binding information.

aroraharsh23 commented 4 years ago

We have added this new label "citrix_server_name" in our new release. It won't impact scrape time much, scrape time is more due to other reasons, which, we are still working on. Closing this.