Re: OpenNMS monitoring and data collection from the Azure REST API
Dino Yancey <[email protected]>
| Newsgroups | gmane.network.opennms.general |
|---|---|
| Message-ID | <CA+GnOzRv1EA8HOgYyZH5HrUMy281A8deE8H9xQjvc+Df+WNDNw@mail.gmail.com> |
https://wiki.opennms.org/wiki/XML_Collector#JSON_Collector On Thu, May 3, 2018 at 10:09 PM, JohnD Blackburn <[email protected] > wrote: > Hi All, > > > > We are currently using OpenNMS 21.1.0 to monitor all our Azure VM’s, and > it has been brought up that there is a whole bunch of metrics and statuses > that are only available through Azure. I have been looking at options for > getting some of this info into OpenNMS, and have found several potential > methods for achieving this. > > > > It is possible to set up webhooks in Azure that get called when events, > statuses, and thresholds are triggered, which could possibly work, but > would require me to set up an internet facing webserver to receive the > webhook calls, and to then process the received JSON data to the correct > node in OpenNMS. This would also require configuration added to Azure to > “send” these details. > > > > A second option I have come across is to use the Azure REST API which is > documented here: https://docs.microsoft.com/en-us/rest/api/azure/ > > > > Using this should allow me to drive the collection from the OpenNMS > server, however I would need to get the mapping between OpenNMS nodes and > Azure resources working. > > > > To be able to get details out of Azure for a specific node, I would need > to know the “SubscriptionID”, “ResourceGroupName” and “ResourceID” from > Azure, and to complicate matters, requests to the Azure API require an > access token which I can get with the following curl commandline which > returns the access token in a JSON formatted file > > > > curl -X POST -d 'grant_type=client_credentials&client_id='$ > CLIENTID'&client_secret='$CLIENTSECRET'&resource=https%3A%2F% > 2Fmanagement.azure.com%2F' https://login.microsoftonline. > com/$TENANTID/oauth2/token > $TOKEN_FILE > > > > This Access token that is returned expires after an hour, so a new access > token would need to be requested every hour. The access token is passed > into the HTTP request as a header. The following curl command shows the > format required for the http request: > > > > curl -X GET -H "Authorization: Bearer $TOKEN_ID" -H "Content-Type: > application/json" https://management.azure.com/$URI > > > > > > That access token is 1335 characters long. > > > > What is the best way to capture data from the Azure REST API? Do I need a > script that runs hourly to update the access token in the asset comment > field and store all those variables in Asset Fields? Would a 1335 > character string be storable in an asset field? > > > > Has anyone implemented any OpenNMS monitoring/data collection from the > Azure REST API? > > > > > > > > Also, Trying to create a collector for the JSON, given the following JSON > as returned by Azure: > > { > > "id": "/subscriptions/SubscriptionID/resourceGroups/ > ResourceGroupName/providers/Microsoft.Compute/virtualMachines/VMName/ > providers/Microsoft.ResourceHealth/availabilityStatuses/current", > > "name": "current", > > "type": "Microsoft.ResourceHealth/AvailabilityStatuses", > > "location": "australiaeast", > > "properties": { > > "availabilityState": "Available", > > "summary": "There aren't any known Azure platform problems affecting > this virtual machine", > > "detailedStatus": "", > > "reasonType": "", > > "occuredTime": "2018-04-26T09:15:52Z", > > "reasonChronicity": "Persistent", > > "reportedTime": "2018-05-04T02:02:47.222185Z" > > } > > } > > > > How would I format the XML Group definition in xml-datacollection? It is > not clear to me from the documentation. > > I’m guessing something like this: > > <xml-groups> > > <xml-group name="azure-test" resource-type="node" > > resource-xpath="/" > > key-xpath="@id"> > > <xml-object name="name" type=”string" xpath="@name" /> > > <xml-object name="type" type="string" xpath="@type" /> > > <xml-object name="location" type="string" xpath="@location" /> > > <xml-object name="availabilityState" type="string" > xpath="properties[@availabilityState]" /> > > <xml-object name="summary" type="string" > xpath="properties[@summary]" /> > > <xml-object name="detailedStatus" type="string" xpath="properties[@detailedStatus]" > /> > > <xml-object name="reasonType" type="string" > xpath="properties[@reasonType]" /> > > <xml-object name="occuredTime" type="string" xpath="properties[@occuredTime]" > /> > > <xml-object name="reasonChronicity" type="string" xpath="properties[@reasonChronicity]" > /> > > <xml-object name="reportedTime" type="string" xpath="properties[@reportedTime]" > /> > > </xml-group> > > </xml-groups> > > > > > > Regards, > > John Blackburn > > > > > > > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Please read the OpenNMS Mailing List FAQ: > http://www.opennms.org/index.php/Mailing_List_FAQ > > opennms-discuss mailing list > > To *unsubscribe* or change your subscription options, see the bottom of > this page: > https://lists.sourceforge.net/lists/listinfo/opennms-discuss > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Please read the OpenNMS Mailing List FAQ: http://www.opennms.org/index.php/Mailing_List_FAQ opennms-discuss mailing list To *unsubscribe* or change your subscription options, see the bottom of this page: https://lists.sourceforge.net/lists/listinfo/opennms-discuss