REST API description: Difference between revisions

no edit summary
No edit summary
Line 73: Line 73:
jquery ( [https://stedolan.github.io/jq/] ) is a powerful tool to extract parameters from a json document. Please read its documentation if you need to postprocess more data.
jquery ( [https://stedolan.github.io/jq/] ) is a powerful tool to extract parameters from a json document. Please read its documentation if you need to postprocess more data.


=== json_pp ===
json_pp is a very simple tool to pretty print json output. It will format the JSON output to make it more readable...


== API hierarchy ==
== API hierarchy ==
Line 180: Line 183:


== API parameters ==
== API parameters ==
The Allegro REST API has a number of query parameters that can be added to modify the request. By default, the API will display the real time counters since the last restart of the processing unit.
<pre>
$ curl --silent -k -u 'admin:allegro'  "https://allegro-mm/API/stats/modules/ip/ips/10.54.0.254?starttime=$(date --date="1 day ago" +%s)&endtime=$(date +%s)" |
{
  "interfaces" : [
      0
  ],
  "firstRecentActivity" : 1588067610,
  "l7RetransBytesRx" : 97,
  "l7RealBytesTx" : 6363134,
  "continentName" : "--",
  "tcpContinuousResponseTimes" : {
      "avg" : 25.183,
      "count" : 1412450,
      "min" : 0.001,
      "stddev" : 911.777,
      "history" : {
        "dataAge" : 1589178163112,
        "intervalAMM" : {
            "min" : 1,
            "count" : 60348,
            "avg" : 5158,
            "max" : 48060
        },
        "data" : [
            1589120000000,
            0,
            0,
            0,
            0,
            1589121024000,
            0,
            0,
...
</pre>
==== Time interval selection ====
By default, the API
Requests can be given a time interval. The following GET parameters are necessary:
* starttime, endtime: Start and end time of the interval. Format: seconds since 1970/01/01 UTC (Unix time, epoch).
* timespan: Duration of the interval selection in seconds.
<pre>
$ curl --silent -k -u 'admin:allegro'  "https://allegro-mm/API/stats/modules/ip/ips/10.54.0.254?starttime=$(date --date="1 day ago" +%s)&endtime=$(date +%s)" | json_pp | head -n 30
{
  "interfaces" : [
      0
  ],
  "firstRecentActivity" : 1588067610,
  "l7RetransBytesRx" : 97,
  "l7RealBytesTx" : 6363134,
  "continentName" : "--",
  "tcpContinuousResponseTimes" : {
      "avg" : 25.183,
      "count" : 1412450,
      "min" : 0.001,
      "stddev" : 911.777,
      "history" : {
        "dataAge" : 1589178163112,
        "intervalAMM" : {
            "min" : 1,
            "count" : 60348,
            "avg" : 5158,
            "max" : 48060
        },
        "data" : [
            1589120000000,
            0,
            0,
            0,
            0,
            1589121024000,
            0,
            0,
...
</pre>
==== Extract received bytes of the last second of a specific IP ====
<code>curl --silent -k -u USER:PASSWORD 'https://allegro-mm-XXXX/API/stats/modules/ip/ips/10.1.2.3' | jq .lastSecond[1]</code>
==== Extract received and transmitted bytes of the last second of a specific IP ====
<code>curl --silent -k -u USER:PASSWORD 'https://allegro-mm-XXXX/API/stats/modules/ip/ips/10.1.2.3' | jq '.lastSecond[1] + .lastSecond[3]'</code>
==== Extract received and transmitted bytes in a time interval (18/06/11 9:00 - 10:00) of a specific IP ====
<code>curl --silent -k -u USER:PASSWORD 'https://allegro-mm-XXXX/API/stats/modules/ip/ips/10.1.2.3?timespan=3600&starttime=1528700400&endtime=1528704000' |  jq '.interval[1] + .interval[3]'</code>




Line 208: Line 305:
* intervalPerSecond: Average per second value of the selected time interval. If no interval is specified, this is similar to lastSecond.
* intervalPerSecond: Average per second value of the selected time interval. If no interval is specified, this is similar to lastSecond.


==== Time interval selection ====
Requests can be given a time interval. The following GET parameters are necessary:
* starttime, endtime: Start and end time of the interval. Format: seconds since 1970/01/01 UTC (Unix time, epoch).
* timespan: Duration of the interval selection in seconds.
==== Extract received bytes of the last second of a specific IP ====
<code>curl --silent -k -u USER:PASSWORD 'https://allegro-mm-XXXX/API/stats/modules/ip/ips/10.1.2.3' | jq .lastSecond[1]</code>
==== Extract received and transmitted bytes of the last second of a specific IP ====
<code>curl --silent -k -u USER:PASSWORD 'https://allegro-mm-XXXX/API/stats/modules/ip/ips/10.1.2.3' | jq '.lastSecond[1] + .lastSecond[3]'</code>
==== Extract received and transmitted bytes in a time interval (18/06/11 9:00 - 10:00) of a specific IP ====
<code>curl --silent -k -u USER:PASSWORD 'https://allegro-mm-XXXX/API/stats/modules/ip/ips/10.1.2.3?timespan=3600&starttime=1528700400&endtime=1528704000' |  jq '.interval[1] + .interval[3]'</code>


==== List queries ====
==== List queries ====
404

edits