Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Event Query Examples

Bhinav Sura edited this page Jul 8, 2017 · 8 revisions

Examples & Screencasts


Argus Web

This example illustrates how to display event annotations alongside metrics within your dashboards. The use of the ag-flags element containing an annotation query, will retrieve the events of interest to display on your chart.

Argus SDK

This simple example illustrates how to retrieve annotations.

public static void main(String[] args) {

    int maxConnections = 10;
    ArgusService service = ArgusService.getInstance("https://argus.mycompany.com/argusws", maxConnections);
    service.getAuthService().login("aUsername", "aPassword");

    try {
        List<String> expressions = Arrays.asList(new String[] {
                        "-1d:TestScope:TestMetric{TestTag=TagValue}:TestType:TestUser"});
        List<Annotation> result = service.getAnnotationService().getAnnotations(expressions);
    } catch(TokenExpiredException e) {
	try {
            // Looks like my access token has expired.
            // So I will obtain a new access token using refresh token.
            service.getAuthService().obtainNewAccessToken();
	} catch(TokenExpiredException e1) {
            // Looks like the refresh token itself has expired.
            // So I will re-login to Argus using username and password.
	    service.getAuthService().login("aUsername", "aPassword");
	} catch (IOException e1) {
            //Handle IOException as you would normally do.
	    e1.printStackTrace();
	}
    } catch (IOException e) {
        //Handle IOException as you would normally do.
	e.printStackTrace();
    } 
}

Curl

This simple example uses curl to retrieve data for the given expression over the trailing day.

#!/bin/bash

curl -X POST -H "Content-Type: application/json" \
     -d '{"username":"aUsername","password":"aPassword"}' \
     https://argus.mycompany.com/argusws/v2/auth/login \
     -o tokens.out

# You can use any utility of your choice to extract the accessToken 
# from the tokens.out file. 

curl -H "Authorization: Bearer <accessToken from tokens.out>" \
     https://argus.mycompany.com/argusws/annotations?expression=-1d:TestScope:TestMetric{TestTag=TestValue}:TestType
Clone this wiki locally