Forum Discussion
Get Status of individual pool monitors via iControl REST
Hi DevCentral community!
I am currently trying to retrieve the status (per individual monitor) for a specific pool or member via iControl REST.
As you can see in the following response, there are currently two monitors (gateway_icmp and http) configured for the given pool, whereas at least one of the monitors needs to be in up state.
GET https://f5.test.lan/mgmt/tm/ltm/pool/~Common~XYZ-Test
{
"kind": "tm:ltm:pool:poolstate",
"name": "XYZ-Test",
"partition": "Common",
"fullPath": "/Common/XYZ-Test",
"monitor": "min 1 of { /Common/gateway_icmp /Common/http }",
"membersReference": {
"link": "https://localhost/mgmt/tm/ltm/pool/~Common~XYZ-Test/members?ver=13.1.0.2",
"isSubcollection": true
}
...
}
However, when trying to get the status of the pool, I only receive information about the total status (in this case up) of the pool, but not the status of the individual monitors.
GET https://f5.test.lan/mgmt/tm/ltm/pool/~Common~XYZ-Test/members
{
"kind": "tm:ltm:pool:members:memberscollectionstate",
"selfLink": "https://localhost/mgmt/tm/ltm/pool/~Common~XYZ-Test/members?ver=13.1.0.2",
"items": [
{
"kind": "tm:ltm:pool:members:membersstate",
"name": "10.0.0.78:1514",
"partition": "Common",
"fullPath": "/Common/10.0.0.78:1514",
"address": "10.0.0.78",
"monitor": "default",
"session": "monitor-enabled",
"state": "up"
...
}
]
}
GET https://f5.test.lan/mgmt/tm/ltm/pool/~Common~XYZ-Test/members/stats
{
"kind": "tm:ltm:pool:members:memberscollectionstats",
"entries": {
"https://localhost/mgmt/tm/ltm/pool/~Common~XYZ-Test/members/~Common~10.0.0.78:1514/stats": {
"nestedStats": {
"kind": "tm:ltm:pool:members:membersstats",
"selfLink": "https://localhost/mgmt/tm/ltm/pool/~Common~XYZ-Test/members/~Common~10.0.0.78:1514/stats?ver=13.1.0.2",
"entries": {
"addr": {
"description": "10.0.0.78"
},
"monitorRule": {
"description": "min 1 of /Common/gateway_icmp /Common/http (pool monitor)"
},
"monitorStatus": {
"description": "up"
},
"nodeName": {
"description": "/Common/10.0.0.78"
},
"poolName": {
"description": "/Common/XYZ-Test"
},
"port": {
"value": 1514
},
"sessionStatus": {
"description": "enabled"
},
"status.availabilityState": {
"description": "available"
},
"status.enabledState": {
"description": "enabled"
},
"status.statusReason": {
"description": "Pool member is available"
},
...
}
}
}
}
}
Is there any way to get the status of the individual monitors (e.g. gateway_icmp --> up, http --> down) for a specific pool, or its members?
Thank you in advance.
- Alexis_125352
Nimbostratus
Hello,
I have exactly the same problem. Impossible to get the status per monitor.
If you found the solution could you share it please ?
Regards, Alexis
- Satoshi_Toyosa1Ret. Employee
Call two endpoints:
and/mgmt/tm/ltm/pool/
./mgmt/tm/ltm/monitor///stats
First, get the pool member and monitor names. Because the references to the pool members are subcollections, you need to add the
query string to expand the references (for more information, see pp. 31-34 in iControl® REST API User Guide Version 12.1😞 e.g.,expandSubcollections=true
curl -sku admin:admin https://localhost/mgmt/tm/ltm/pool/vmnet2-80?\expandSubcollections=true
The call yields (abridged for readability sake):
{ ... "fullPath": "vmnet2-80", ... "membersReference": { "isSubcollection": true, "items": [ { "address": "10.200.20.137", ... "fullPath": "/Common/CentOS-vmnet2:80", ... "address": "10.200.20.80", ... "fullPath": "/Common/Fedora-vmnet2:80", ... "monitor": "min 1 of { /Common/gateway_icmp /Common/http }", .... }
In this example, the pool
has two members:vmnet2-80
and10.200.20.137:80
. Two monitors are attached to the pool:10.200.20.80:80
andgateway_icmp
, and the availability requirement is "at least ... 1 health monitor(s)".http
Then, get the stats from the two monitors. e.g.,
curl -sku admin:admin https://localhost/mgmt/tm/ltm/monitor/gateway-icmp/gateway_icmp/stats curl -sku admin:admin https://localhost/mgmt/tm/ltm/monitor/http/http/stats
Note that you need to specify the monitor type (e.g., gateway-icmp) and monitor (gateway_icmp) just like the equivalent
command. The call yields (abridged):tmsh
... LTM::Monitor /Common/gateway_icmp ----------------------------------- Destination: 10.200.20.80:0 State time: up for 0hr:49mins:44sec <<< This one is UP | Last error: N/A @2018.04.16 11:34:28 Destination: 10.200.20.137:0 State time: up for 1hr:22mins:46sec <<< ditto | Last error: N/A @2018.04.16 11:01:26 ... LTM::Monitor /Common/http --------------------------- Destination: 10.200.20.80:80 State time: down for 0hr:41mins:52sec <<< This one is DOWN. | Last error: Unable to connect No successful responses received before deadline. @2018.04.16 11:45:28 Destination: 10.200.20.137:80 State time: down for 0hr:44mins:25sec <<< ditto | Last error: Unable to connect No successful responses received before deadline. @2018.04.16 11:42:55
As you can see, the output is exactly same as
. Because the iControl REST puts all the tmsh output in one blob to thetmsh show ltm monitor
field after converting '\n' (LF) to the literal '\n' (backslash and n), you may want to parse it usingapiAnonymous
or something similar: e.g.,sed
curl -sku admin:admin https://localhost/mgmt/tm/ltm/monitor/http/http/stats | python -m json.tool | grep apiAnonymous | sed 's/\\n/\n/g'
Because there are multiple queries and field look-ups involved, you may want to write a script. You have a number of choices: bash (call curl), PowerShell, Ansible or F5 Python SDK.
- Alexis_125352
Nimbostratus
Hello Satoshi,
Thank you very much for you're detailled answer.
I tested your solution and it looks great when I work on monitors hosted on the Common partition, but when I try on monitors hosted on user defined partitions it fails :
curl -sku admin:password https://10.200.2.92/mgmt/tm/ltm/monitor/https/~PART1~https_1_0_443/stats?ver=12.1.3 | python -m json.tool { "apiError": 1, "code": 404, "errorStack": [], "message": "Object not found - /PART1/https_1_0_443" }
Am I doing it the right way ? Is there any workaround ?
PS : The object /PART1/https_1_0_443 actually exists
- Dominik_312933
Nimbostratus
Yes, I am experiencing the same issue.
A GET request to
https://f5.intern/mgmt/tm/ltm/monitor/gateway-icmp/~Common~gateway_icmp/stats
triggers the expected response (containing the "apiRawValues" field).
However, a GET request to
https://f5.intern/mgmt/tm/ltm/monitor/http/~PART1~http_mon_1/stats
triggers 404 Object not found.
On the other hand a monitor in a custom partition, wrapped in an iApp works as expected. A GET request to
https://f5.intern/mgmt/tm/ltm/monitor/http/~PART1~MYAPP.app~MYAPP_http_mon_2/stats
triggers the expected response (containing the "apiRawValues" field).
This is a really strange behavior, whereas I would be very interested in a workaround other than using an iApp.
- Satoshi_ToyosawHistoric F5 Account
Perhaps the monitor is not attached to a pool.
Change to a folder (partition) root@(ltm1311)(cfg-sync Standalone)(Active)(/Common)(tmos) cd /TestFolder/ Verify the monitor in this partition. Yes, it's there. root@(ltm1311)(cfg-sync Standalone)(Active)(/TestFolder)(tmos) list ltm monitor http TestMonitor ltm monitor http TestMonitor { adaptive disabled defaults-from /Common/http destination *:* interval 5 ip-dscp 0 partition TestFolder recv none recv-disable none send "GET /HelloWorld.html\r\n" time-until-up 0 timeout 16 } Can I see the stats? No. root@(ltm1311)(cfg-sync Standalone)(Active)(/TestFolder)(tmos) show ltm monitor http TestMonitor Check the pool. I don't have any pool on this folder. root@(ltm1311)(cfg-sync Standalone)(Active)(/TestFolder)(tmos) list ltm pool Let's create one. Attach the monitor on the /TestFolder. root@(ltm1311)(cfg-sync Standalone)(Active)(/TestFolder)(tmos) create ltm pool TestPool monitor TestMonitor members add { /Common/CentOS-internal20:80 } Double check it is there. root@(ltm1311)(cfg-sync Standalone)(Active)(/TestFolder)(tmos) list ltm pool ltm pool TestPool { members { /Common/CentOS-internal20:http { address 10.200.20.137 session monitor-enabled state up } } monitor TestMonitor partition TestFolder } Now show me the stats root@(ltm1311)(cfg-sync Standalone)(Active)(/TestFolder)(tmos) show ltm monitor http TestMonitor -------------------------------------- LTM::Monitor /TestFolder/TestMonitor -------------------------------------- Destination: 10.200.20.137:80 State time: up for 0hr:0min:8sec | Last error: N/A @2018.04.19 15:49:14
Now check the monitor stats via iControl REST
curl -sku admin:admin https://localhost/mgmt/tm/ltm/monitor/http/~TestFolder~TestMonitor/stats | sed 's/\\n/\n/g' {"kind":"tm:ltm:monitor:http:httpstats","generation":0,"selfLink":"https://localhost/mgmt/tm/ltm/monitor/http/~TestFolder~TestMonitor/stats?ver=13.1.0","apiRawValues":{"apiAnonymous":"-------------------------------------- LTM::Monitor /TestFolder/TestMonitor -------------------------------------- Destination: 10.200.20.137:80 State time: up for 0hr:8mins:7sec | Last error: N/A @2018.04.19 15:49:14
- Findus
Altostratus
Facing the same issue, version 12.1.x and 13.1.0.7. Doesn´t matter if the monitor is assigned to a pool or not, in both cases a 404 not found is received. No problems when monitor resides in Common partition.
- Satoshi_Toyosa1Ret. Employee
You should raise a ticket to F5 Support since so you can share more data for troubleshooting.
- Findus
Altostratus
After retesting i found out that a monitor´s stats can only be queried when the monitor is attached to a pool with members in it (as mentioned already by Satoshi). If the monitor is not attached to a pool or is attached to a pool without actual members, it will not show any stats and LTM will respond with a "404 object not found". This is true for both the Common partition and subpartitions.
Tested under 13.1.0.8 and 12.1.3.4
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com