How to get events filtered by particular servers using the OverOps API (an example walkthrough) Follow

1.) Create a view for the servers in question

Create a view manually via the GUI with servers you wish to filter for.

  1. On the "classic dashboard" (the main GUI page) Click on "App Apps / Deployments / Servers"
  2. Select the servers tab
  3. Select the individual servers you wish to filter for
    You might have to uncheck the show active servers slider at the bottom to show more servers not recently seen
  4. Click "Apply"
  5. Click the "Save View" button
  6. Give it a name
  7. Click Next
  8. Click Save & Finish     

 

2.) Set your variables in your script

APIKEY=YOUR_API_KEY_HERE # substitute your api key here
ENV_ID=YOUR_ENVIRONMENT_ID_HERE  # Substitute your environment id here, example S41149

 

3.) Set the time range

Set the time range for which you wish to search for events on these servers:

# For example:
FROM="2020-01-01T00:00:00.00Z"
TO="2020-02-01T00:00:00.00Z"

 

4.) Get the View ID of the view you created.

List the views of the environment (via the APIs) to get the view ID of the view you just created

(For a reference see "List views" in our API documentation).

On the API documentation page, you can click the python tab to get similar examples in python. Other languages are available as well. 

Views.png

curl -H "x-api-key: $APIKEY" --request GET --url https://api.overops.com/api/v1/services/$ENV_ID/views

 

5.) Find in the JSON output from the command above the view id

In this example P2678880 is the view ID of the view I created which was named "testview2":

{"id": "P2678758","name": "testview2"

We will use the above view ID to find events using that view which will filter by the server for us:

VIEWID=P2678758

Fetch event details API

For reference see Fetch stats for all events in the specified view.

 

6.) Get the events/exceptions

Finally, we can now retrieve the events/exceptions for only the servers that we listed in our view:

curl -H "x-api-key: $APIKEY" --request GET --url "https://api.overops.com/api/v1/services/$ENV_ID/views/$VIEWID/events/stats?from=${FROM}&to=${TO}"

 

Sample Output

Here is sample output showing the events/exceptions (5 events were found in this example below):

 {
  "events": [
    {
      "id": "16",
      "stats": {
        "hits": 356,
        "invocations": 0,
        "contributors": [
          {
            "hits": 356,
            "invocations": 0
          }
        ]
      }
    },
    {
      "id": "13",
      "stats": {
        "hits": 89,
        "invocations": 0,
        "contributors": [
          {
            "hits": 89,
            "invocations": 0
          }
        ]
      }
    },
    {
      "id": "3",
      "stats": {
        "hits": 1,
        "invocations": 0,
        "contributors": [
          {
            "hits": 1,
            "invocations": 0
          }
        ]
      }
    },
    {
      "id": "2",
      "stats": {
        "hits": 2025,
        "invocations": 0,
        "contributors": [
          {
            "hits": 2025,
            "invocations": 0
          }
        ]
      }
    },
    {
      "id": "1",
      "stats": {
        "hits": 5,
        "invocations": 0,
        "contributors": [
          {
            "hits": 5,
            "invocations": 0
          }
        ]
      }
    }
  ]
}

 

 

Comments

0 comments