Re: OpenNMS monitoring and data collection from the Azure REST API
JohnD Blackburn <[email protected]>
| Newsgroups | gmane.network.opennms.general |
|---|---|
| Message-ID | <DB6PR0602MB290219B7409681717CC33DABCB9A0@DB6PR0602MB2902.eurprd06.prod.outlook.com> |
David, Sure. Do you want me to post here in OpenNMS Discuss or elsewhere? Regards, John -----Original Message----- From: David Hustace [mailto:[email protected]] Sent: Saturday, 5 May 2018 12:22 AM To: DiscussionList List <[email protected]> Subject: Re: [opennms-discuss] OpenNMS monitoring and data collection from the Azure REST API CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. John, Would you mind spending some time with us writing up your requirements and and putting some user stories together for an Azure monitoring project? Sounds like it would be a fun project. David Hustace The OpenNMS Group, Inc. > On May 3, 2018, at 23:09, 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://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Frest%2Fapi%2Fazure%2F&data=02%7C01%7Cjohnd.blackburn%40au.abb.com%7Cdb5ad0a843944327f76a08d5b1ca9065%7C372ee9e09ce04033a64ac07073a91ecd%7C0%7C0%7C636610405921731316&sdata=mvxkWkHQOw%2BYXenXMSXH5EBt63t3qxzlAW%2Byu9E%2BqPs%3D&reserved=0 > > 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://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flogin.microsoftonline.com%2F%24TENANTID%2Foauth2%2Ftoken&data=02%7C01%7Cjohnd.blackburn%40au.abb.com%7Cdb5ad0a843944327f76a08d5b1ca9065%7C372ee9e09ce04033a64ac07073a91ecd%7C0%7C1%7C636610405921887567&sdata=2UBHpeqHHjtVOBu%2F1krg33LRKcRsA8yhPFwaBW53meI%3D&reserved=0 > $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://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmanagement.azure.com%2F%24URI&data=02%7C01%7Cjohnd.blackburn%40au.abb.com%7Cdb5ad0a843944327f76a08d5b1ca9065%7C372ee9e09ce04033a64ac07073a91ecd%7C0%7C1%7C636610405921887567&sdata=8IHbgyXsr%2F%2B%2Fy5v9BADZkeP41jE%2FHCZLonRVH%2Bw0jbg%3D&reserved=0 > > > 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! https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsdm.link%2Fslashdot_______________________________________________&data=02%7C01%7Cjohnd.blackburn%40au.abb.com%7Cdb5ad0a843944327f76a08d5b1ca9065%7C372ee9e09ce04033a64ac07073a91ecd%7C0%7C1%7C636610405921887567&sdata=kHFZC4jFGMUcJ8IZzC%2BgUK4muKXj0xWT%2B%2F%2B2hC45%2FeM%3D&reserved=0 > Please read the OpenNMS Mailing List FAQ: > https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.opennms.org%2Findex.php%2FMailing_List_FAQ&data=02%7C01%7Cjohnd.blackburn%40au.abb.com%7Cdb5ad0a843944327f76a08d5b1ca9065%7C372ee9e09ce04033a64ac07073a91ecd%7C0%7C1%7C636610405921887567&sdata=TLjUlAz1uQtxS5CkqblqEDBK%2FOOlPPGgBn42LzDK7HQ%3D&reserved=0 > > opennms-discuss mailing list > > To *unsubscribe* or change your subscription options, see the bottom of this page: > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fopennms-discuss&data=02%7C01%7Cjohnd.blackburn%40au.abb.com%7Cdb5ad0a843944327f76a08d5b1ca9065%7C372ee9e09ce04033a64ac07073a91ecd%7C0%7C1%7C636610405921887567&sdata=bHJeVeS%2Blmn%2FQdfMvBG%2Fn7409l%2F0oOirCdOoLsmn%2FnM%3D&reserved=0 ------------------------------------------------------------------------------ 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