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

Metric Query Examples

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

Examples & Screencasts


Argus Web

This short screencast demonstrates how to perform a simple metric query using the discovery lookup.

Argus SDK

This simple example illustrates how to retrieve metrics.

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}:sum:TestNamespace"});
        List<Metric> result = service.getMetricService().getMetrics(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/metrics?expression=-1d:TestScope:TestMetric{TestTag=TagValue}:sum:TestNamespace