Datasource

Search and query

The control charts building block also exposes two additional endpoints, that follow the standard of a grafana datasource. The endpoints can be used to get a list of control charts, and the datapoints of a single chart with its errors, or a metric datapoints.

POST methods

POST /api/v1/search

Returns a list of control charts or metrics that can be used as a target in a query request.

Each element of the array represents a single chart and is defines as a combination of chart type, metric label and chart id, separeted by :

In case of metrics, only the metric label is exposed. In order to get a list of metrics a query parameter with metrics key has to be defined: for example ?metrics=true

Example request:

POST /api/v1/search HTTP/1.1
Host: https://ccharts.hir.facts4.work/
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Content-type: application/json

[
  "range:sample.euromap63_10.injection_spindle_temperatures:f4697e75-0fad-4ca6-a89b-26426fbb3871",
  "individual:sample.euromap63_10.injection_spindle_temperatures:d51caa47-a979-43b7-b61f-f8fe0d4a6201",
  "range:sample.euromap63_10.plastification_time:8d37bb9a-24f1-4941-aec2-4dfb01fb3001",
  "individual:sample.euromap63_10.plastification_time:1dfa0666-f7b0-41e7-83fc-56fd13eb1d57",
  "range:local.sample.monoasc:942c903b-8827-4bb2-a5bc-49dc5e2209a6",
  "individual:local.sample.monoasc:c20edc94-b27f-4c9f-b548-2b0391ca0271",
  "individual:local.sample.monodesc:f20f69e2-05e4-4c76-9acc-324570f9556e",
  "range:local.sample.monodesc:f5292c61-0f3f-4892-9d4a-be485d78e55b"
]
Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
  • metrics (string) – any value different from null to get metrics, instead of charts
Response JSON Array of Objects:
 
  • chart (string) – type:metric:chart_id
  • chartmetric_label
Status Codes:
POST /api/v1/query

Returns a single metric datapoints or a single control charts datapoints and errors in the specified time frame.

Required field in the request body are targets and one of rangeRelative or range. targets is an array of JSON object with string value of the requested chart.

target can refer to a metric or a chart. In case it is a metric the format used is metric:metric_id, while if it’s a chart the format is type:metric_label:chart_id.

rangeRelative and range define the time interval for which datapoints and errors are returned. rangeRelative has precedence over range, so defining both will result in rangeRelative being used. Both of the fields have two fields, from and to, where from is required, while to can be omitted. If to is not defined that the time series returned will be in the time interval from until the current time. rangeRelative fields are defined in a relative time, and since it will be calculated relative to the current time, they have the minus sign. Abbreviations are show in the table bellow.

range is defined in absolute time following the ISO 8601 format.

Abbreviation Units
s seconds
min minutes
h hours
d days
w weeks
mon month
y year

In the example request, since both range and rangeRelative are defined, the time interval of the returned datapoints will be the one of rangeRelative and will be from 8 hours before the current time til 5 minutes before current time.

Other than the errors that are included in the datapoints, these additional timeseries are present: X is the original timeseries of the chart, mean is the mean, UCL is the upper control limit, LCL lower control limit. Since mean, UCL and LCL are constant lines, they are represented by two datapoints, one at the beginning of the time frame and one at the end, with the same value. Additionaly, if specification limits are defined, they are exposed as specification LCL and specification UCL.

Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
Response JSON Array of Objects:
 
  • target (string) – name of the time series
  • datapoints (array) – array of tuples with UNIX timestamp and value
Status Codes:

Example request Metric:

POST /api/v1/query HTTP/1.1
Host: https://ccharts.hir.facts4.work/
Content-Type: application/json

{
  "rangeRelative": {
    "from": "-5min"
  },
  "targets": [
    { "target": "metric:dd9633f6-df3a-4bfb-9dfc-8e2fd73805fd" }
  ]
}

Example response:

HTTP/1.1 200 OK
Content-type: application/json

[
    {
        "target": "local.sample.monoasc",
        "datapoints": [
            [
                2.9786,
                1504084960000
            ],
            [
                3.8216,
                1504084970000
            ],
            [
                4.4477,
                1504084980000
            ],
            [
                2.0268,
                1504084990000
            ],
            [
                1.0134,
                1504085000000
            ],
            [
                3.2654,
                1504085010000
            ],
            [
                0.7319,
                1504085020000
            ],
            [
                4.504,
                1504085030000
            ],
            [
                0.4512,
                1504085040000
            ],
            [
                2.3124,
                1504085050000
            ],
            [
                2.7072,
                1504085060000
            ],
            [
                2.7072,
                1504085070000
            ],
            [
                null,
                1504085080000
            ],
            [
                2.5944,
                1504085090000
            ],
            [
                4.0115,
                1504085100000
            ],
            [
                0.791,
                1504085110000
            ],
            [
                2.26,
                1504085120000
            ],
            [
                4.407,
                1504085130000
            ],
            [
                3.5595,
                1504085140000
            ],
            [
                0.5085,
                1504085150000
            ],
            [
                5.0374,
                1504085160000
            ],
            [
                1.0754,
                1504085170000
            ],
            [
                4.8676,
                1504085180000
            ],
            [
                5.4336,
                1504085190000
            ],
            [
                1.9244,
                1504085200000
            ],
            [
                1.0754,
                1504085210000
            ],
            [
                4.8762,
                1504085220000
            ],
            [
                0.9639,
                1504085230000
            ],
            [
                1.8711,
                1504085240000
            ],
            [
                5.6133,
                1504085250000
            ]
        ]
    }
]

Example request Chart:

POST /api/v1/query HTTP/1.1
Host: https://ccharts.hir.facts4.work/
Content-Type: application/json

{
  "range": {
    "from": "2017-05-01T11:33:44.866Z",
    "to": "2017-05-01T12:33:44.866Z"
  },
  "rangeRelative": {
    "from": "-8h",
    "to": "-5min"
  },
  "targets": [
    { "target": "range:sample.euromap63_10.injection_spindle_temperatures:f4697e75-0fad-4ca6-a89b-26426fbb3871" }
  ]
}

Example response:

HTTP/1.1 200 OK
Content-type: application/json

[
  {
    "target": "unbalanced",
    "datapoints": [
      [
        0.2808,
        1493898130000
      ],
      [
        1.1232,
        1493898140000
      ],
      [
        5.4054,
        1493898150000
      ],
      [
        4.8438,
        1493898160000
      ],
      [
        1.4742,
        1493898170000
      ],
      [
        0.2812,
        1493898180000
      ],
      [
        1.406,
        1493898190000
      ],
      [
        1.406,
        1493898200000
      ]
    ]
  },
  {
    "target": "outside_sigma",
    "datapoints": [
      [
        4.8438,
        1493898160000
      ],
      [
        1.4742,
        1493898170000
      ],
      [
        0.2812,
        1493898180000
      ],
      [
        1.406,
        1493898190000
      ],
      [
        6.2656,
        1493898270000
      ],
      [
        1.3376,
        1493898280000
      ],
      [
        1.2672,
        1493898290000
      ],
      [
        0.282,
        1493898300000
      ]
    ]
  },
  {
    "target": "X",
    "datapoints": [
      [
        0.2808,
        1493898130000
      ],
      [
        1.1232,
        1493898140000
      ],
      [
        5.4054,
        1493898150000
      ],
      [
        4.8438,
        1493898160000
      ],
      [
        1.4742,
        1493898170000
      ],
      [
        0.2812,
        1493898180000
      ],
      [
        1.406,
        1493898190000
      ],
      [
        1.406,
        1493898200000
      ],
      [
        1.8981,
        1493898210000
      ],
      [
        6.8894,
        1493898220000
      ],
      [
        2.4605,
        1493898230000
      ],
      [
        4.9984,
        1493898240000
      ],
      [
        4.9984,
        1493898250000
      ],
      [
        3.2384,
        1493898260000
      ],
      [
        6.2656,
        1493898270000
      ],
      [
        1.3376,
        1493898280000
      ],
      [
        1.2672,
        1493898290000
      ],
      [
        0.282,
        1493898300000
      ]
    ]
  },
  {
    "target": "UCL",
    "datapoints": [
      [
        14.938356430030526,
        1493898120000
      ],
      [
        14.938356430030526,
        1493898300000
      ]
    ]
  },
  {
    "target": "LCL",
    "datapoints": [
      [
        -4.058672149094063,
        1493898120000
      ],
      [
        -4.058672149094063,
        1493898300000
      ]
    ]
  },
  {
    "target": "mean",
    "datapoints": [
      [
        5.439842140468231,
        1493898120000
      ],
      [
        5.439842140468231,
        1493898300000
      ]
    ]
  }
]