05-14-2021 09:20 AM - edited 05-14-2021 09:24 AM
Hey team!
I was wondering if you know how I could get the data that is displayed in a APIC dashboard System Health during the day.
I would like to replicate that data in other format so I can attach it in a report.
I found that I could get data through an api call to this object: fabricOverallHealthHist5min. However the api call only returns one value.
I hope you could help me.
I attached the dashboard that I was talking about.
Thanks,
Hernan M
05-15-2021 01:57 AM
Hi @hm.perccami
If you do a GET for fabricOverallHealthHist5min, you will get the current value of the object.
What you can do to get the full history, is to do a GET to https://{{apic_ip}}/api/node/mo/topology.json?rsp-subtree-include=stats&rsp-subtree-class=fabricOverallHealthHist5min
If you are asking me how I found out the correct URL to use, well I used API Inspector. You start the API inspector:
Then you opened the System Dashboard page, and voila:
Stay safe,
Sergiu
05-17-2021 10:38 AM
Using the always-on ACI sandbox we can test the above solution like so. I will use curl commands as that is available on all systems. However, the answer can be translated to anything such as Postman or Python as well.
Access the always-on ACI sandbox by following this link https://devnetsandbox.cisco.com/RM/Topology. Then Click on ACI Simulator 4.2, it's at the top.
After opening it, it will tell you the endpoint, username/password: sandboxapicdc.cisco.com, admin/ciscopsdt
Here are the example curl commands. I use -i to show the response headers. -X to specify the HTTP request method. -d is used to supply the data.
We login using the api/aaaLogin.json path using a POST method. It has a JSON template to properly login and we put the username and password in there.
# curl https://sandboxapicdc.cisco.com/api/aaaLogin.json -i -X POST -d '{"aaaUser" : {"attributes" : {"name" : "admin","pwd" : "ciscopsdt" }}}' OUTPUT: HTTP/2 200 server: nginx/1.13.12 date: Mon, 17 May 2021 17:03:55 GMT content-type: application/json content-length: 1306 set-cookie: APIC-cookie=cCcAAAAAAAAAAAAAAAAAAJ+erbyCZjjkVAv1OeCci2sBawD8woUrUVK8sL6LIO9NTX/5KwfVPQTYTqtAMtNNzXUgVJsYLUkXp5Pk7vfrIPTZymWBe9NzdGVRsXnQAJ0GVP+kxa1Bts5TP51XUS33tex9zJS+MxjfG1aUnTddpDsmJb2zQzgVSHbcOjg5/DJ+J23Kx2TLf1jSHdabC57G9w==; path=/; HttpOnly; HttpOnly; Secure access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, devcookie, APIC-challenge access-control-allow-methods: POST,GET,OPTIONS,DELETE x-frame-options: SAMEORIGIN strict-transport-security: max-age=31536000; includeSubdomains cache-control: no-cache="Set-Cookie, Set-Cookie2" client-cert-enabled: false access-control-allow-origin: http://127.0.0.1:8000 access-control-allow-credentials: false {"totalCount":"1","imdata":[{"aaaLogin":{"attributes":{"token":"cCcAAAAAAAAAAAAAAAAAAJ+erbyCZjjkVAv1OeCci2sBawD8woUrUVK8sL6LIO9NTX/5KwfVPQTYTqtAMtNNzXUgVJsYLUkXp5Pk7vfrIPTZymWBe9NzdGVRsXnQAJ0GVP+kxa1Bts5TP51XUS33tex9zJS+MxjfG1aUnTddpDsmJb2zQzgVSHbcOjg5/DJ+J23Kx2TLf1jSHdabC57G9w==","siteFingerprint":"VOtffuqiyWZjv/iI","refreshTimeoutSeconds":"600","maximumLifetimeSeconds":"86400","guiIdleTimeoutSeconds":"1200","restTimeoutSeconds":"90","creationTime":"1621280160","firstLoginTime":"1621280160","userName":"admin","remoteUser":"false","unixUserId":"15374","sessionId":"D+DxLWA7RQOygbf+La/viw==","lastName":"","firstName":"","changePassword":"no","version":"4.1(1k)","buildTime":"Mon May 13 16:27:03 PDT 2019","node":"topology/pod-1/node-1"},"children":[{"aaaUserDomain":{"attributes":{"name":"all","rolesR":"admin","rolesW":"admin"},"children":[{"aaaReadRoles":{"attributes":{}}},{"aaaWriteRoles":{"attributes":{},"children":[{"role":{"attributes":{"name":"admin"}}}]}}]}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-infra","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-mgmt","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-common","readPrivileges":"admin","writePrivileges":"admin"}}}]}}]}
In the output you will see the APIC-cookie which can be used for subsequent requests (to login/authenticate). Note the APIC-cookie has the same value as the Authentication Token in the JSON output.
The cookie looks like this:
APIC-cookie=cCcAAAAAAAAAAAAAAAAAAJ+erbyCZjjkVAv1OeCci2sBawD8woUrUVK8sL6LIO9NTX/5KwfVPQTYTqtAMtNNzXUgVJsYLUkXp5Pk7vfrIPTZymWBe9NzdGVRsXnQAJ0GVP+kxa1Bts5TP51XUS33tex9zJS+MxjfG1aUnTddpDsmJb2zQzgVSHbcOjg5/DJ+J23Kx2TLf1jSHdabC57G9w==
There are other cookies, but we can ignore them.
We can use that cookie in the next request (which is the one you are curious about). This cookie takes care of the authentication. We set the cookies we want to send in the HTTP request using the following argument: -b 'key=value'.
# curl 'https://sandboxapicdc.cisco.com/api/node/mo/topology.json?rsp-subtree-include=stats&rsp-subtree-class=fabricOverallHealthHist5min' -i -X GET -b 'APIC-cookie=cCcAAAAAAAAAAAAAAAAAAJ+erbyCZjjkVAv1OeCci2sBawD8woUrUVK8sL6LIO9NTX/5KwfVPQTYTqtAMtNNzXUgVJsYLUkXp5Pk7vfrIPTZymWBe9NzdGVRsXnQAJ0GVP+kxa1Bts5TP51XUS33tex9zJS+MxjfG1aUnTddpDsmJb2zQzgVSHbcOjg5/DJ+J23Kx2TLf1jSHdabC57G9w==' OUTPUT: HTTP/2 200 server: nginx/1.13.12 date: Mon, 17 May 2021 17:18:10 GMT content-type: application/json content-length: 31143 access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, devcookie, APIC-challenge access-control-allow-methods: POST,GET,OPTIONS,DELETE x-frame-options: SAMEORIGIN strict-transport-security: max-age=31536000; includeSubdomains cache-control: no-cache="Set-Cookie, Set-Cookie2" client-cert-enabled: false access-control-allow-origin: http://127.0.0.1:8000 access-control-allow-credentials: false {"totalCount":"1","imdata":[{"fabricTopology":{"attributes":{"childAction":"","dn":"topology","lcOwn":"local","modTs":"2021-05-17T12:26:43.901+00:00","monPolDn":"uni/fabric/monfab-default","status":""},"children":[{"fabricOverallHealthHist5min":{"attributes":{"childAction":"","cnt":"30","healthAvg":"69","healthMax":"89","healthMin":"0","healthSpct":"0","healthThr":"","healthTr":"-18","index":"2","lastCollOffset":"300","repIntvEnd":"2021-05-17T19:39:02.746+00:00","repIntvStart":"2021-05-17T19:34:02.655+00:00","rn":"HDfabricOverallHealth5min-2","status":""}}},{"fabricOverallHealthHist5min":{"attributes":{"childAction":"","cnt":"30","healthAvg":"87","healthMax":"89","healthMin":"82","healthSpct":"0","healthThr":"","healthTr":"16","index":"3","lastCollOffset":"300","repIntvEnd":"2021-05-17T19:34:02.655+00:00","repIntvStart":"2021-05-17T19:29:02.561+00:00","rn":"HDfabricOverallHealth5min-3","status":""}}}, ... continued ...
05-18-2021 07:23 PM
This info is what I was looking for!
Thanks, Sergiu!
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:
This community is intended for developer topics around Data Center technology and products. If you are looking for a non-developer topic about Data Center, you might find additional information in the Data Center and Cloud community