Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

REST API

azukiwasher edited this page Jul 11, 2012 · 33 revisions

GET /metrics

Description

Returns a list of available metrics that match one or more filtering options by using the query parameters. The REST API returns the results in the JSON or CSV format. For the CSV format, each row is located on a separate line, delimited by a line break (LF) and its fields, separated by commas, never contain line breaks (LF), double quotes and commas.

URL

https://papi.giraffi.jp/metrics.:format

Method

GET

Request Headers

Request with CSV

Content-Type: text/csv

Request with JSON

Content-Type: application/json

Format

metrics.json and metrics.csv are available.

Parameters

The following query parameters are available for authenticating, ordering, limiting and filtering the results when retrieving metrics. All parameters are optional except apikey.

  • apikey: Specifies the authentication token to access to the API resources.
  • src: Specifies the source, e.g., virtualized server instance where the metrics have been collected.
  • tags: Array parameter that selects the metrics corresponding to tags.
  • since: Limits the metrics collected after the given date. Date should be formatted as the Unix epoch time.
  • until: Limits the metrics collected before the given date. Date should be formatted as the Unix epoch time.
  • limit: Specifies the number of results to return. Defaults to 10.
  • offset: Specifies the number of results to skip.
  • order: Orders the results by its time field. asc and desc are available.
  • fields: Array parameter that specifies the fields to return. The available field names are val, time, src and tags.

Example

All available metrics for the specified source:

https://papi.giraffi.jp/metrics.csv?apikey=sTyBGlV-LsQcI8mhMYI3nvqtkYvVoERMb-mz8yhhgCU&4src=cld257-0.m.xenzai.com&fields=val,time

All available metrics corresponding to tags for the specified source:

https://papi.giraffi.jp/metrics.csv?apikey=sTyBGlV-LsQcI8mhMYI3nvqtkYvVoERMb-mz8yhhgCU&src=cld257-0.m.xenzai.com&tags=cpu,7,user&fields=val,time,tags

Response Code

200 OK

Response Headers

** Not Applicable **	

Response Body

Request with CSV

https://papi.giraffi.jp/metrics.csv?apikey=sTyBGlV-LsQcI8mhMYI3nvqtkYvVoERMb-mz8yhhgCU&src=cld257-0.m.xenzai.com&tags=cpu,7,user&fields=val,time,tags

Response

5246016,1341810982.941,cpu,7,cpu,user,derive,value
5246016,1341810982.946,cpu,7,cpu,user,derive,value
5246016,1341810983.031,cpu,7,cpu,user,derive,value
5246016,1341810983.236,cpu,7,cpu,user,derive,value
5246017,1341810983.384,cpu,7,cpu,user,derive,value
# snip..

Request with JSON

https://papi.giraffi.jp/metrics.json?apikey=sTyBGlV-LsQcI8mhMYI3nvqtkYvVoERMb-mz8yhhgCU&src=cld257-0.m.xenzai.com&tags=cpu,7,user&fields=val,time,tags&order=asc&limit=5

Response

[
    {
        "time": 1341810982.941,
        "val": 5246016,
        "tags": [
            "cpu",
            "7",
            "cpu",
            "user",
            "derive",
            "value"
        ]
    },
    {
        "time": 1341810982.946,
        "val": 5246016,
        "tags": [
            "cpu",
            "7",
            "cpu",
            "user",
            "derive",
            "value"
        ]
    },
    {
        "time": 1341810983.031,
        "val": 5246016,
        "tags": [
            "cpu",
            "7",
            "cpu",
            "user",
            "derive",
            "value"
        ]
    },
    {
        "time": 1341810983.236,
        "val": 5246016,
        "tags": [
            "cpu",
            "7",
            "cpu",
            "user",
            "derive",
            "value"
        ]
    },
    {
        "time": 1341810983.384,
        "val": 5246017,
        "tags": [
            "cpu",
            "7",
            "cpu",
            "user",
            "derive",
            "value"
        ]
    }
]

Clone this wiki locally