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

Invalid API response returned by mock collector #1048

Closed
obourdon opened this issue Jul 5, 2016 · 3 comments
Closed

Invalid API response returned by mock collector #1048

obourdon opened this issue Jul 5, 2016 · 3 comments

Comments

@obourdon
Copy link
Contributor

obourdon commented Jul 5, 2016

Having loaded the snap-collector-mock2 plugin I found out that the following call returned an error:

$ snapctl metric get -m /intel/mock/*
Received an invalid API response (META/TYPE)

Looking at the REST response contents seems like snapd returns the following contents:

{
  "meta": {
    "code": 200,
    "message": "Metric",
    "type": "metrics_returned",
    "version": 1
  },
  "body": [
    {
      "last_advertised_timestamp": 1467622295,
      "namespace": "/intel/mock/*/baz",
      "version": 2,
      "dynamic": true,
      "dynamic_elements": [
        {
          "index": 2,
          "name": "host",
          "description": "name of the host"
        }
      ],
      "description": "mock description",
      "unit": "mock unit",
      "href": "http://localhost:8181/v1/metrics/intel/mock/*/baz?ver=2"
    },
    {
      "last_advertised_timestamp": 1467622295,
      "namespace": "/intel/mock/bar",
      "version": 2,
      "dynamic": false,
      "description": "mock description",
      "unit": "mock unit",
      "href": "http://localhost:8181/v1/metrics/intel/mock/bar?ver=2"
    },
    {
      "last_advertised_timestamp": 1467622295,
      "namespace": "/intel/mock/foo",
      "version": 2,
      "dynamic": false,
      "description": "mock description",
      "unit": "mock unit",
      "policy": [
        {
          "name": "password",
          "type": "string",
          "required": true
        },
        {
          "name": "name",
          "type": "string",
          "default": "bob",
          "required": false
        }
      ],
      "href": "http://localhost:8181/v1/metrics/intel/mock/foo?ver=2"
    }
  ]
}

Note that in the case where a single metric is returned here is the REST API response contents

{
  "meta": {
    "code": 200,
    "message": "Metric returned",
    "type": "metric_returned",
    "version": 1
  },
  "body": {
    "Metric": {
      "last_advertised_timestamp": 1467622295,
      "namespace": "/intel/mock/foo",
      "version": 2,
      "dynamic": false,
      "description": "mock description",
      "unit": "mock unit",
      "policy": [
        {
          "name": "password",
          "type": "string",
          "required": true
        },
        {
          "name": "name",
          "type": "string",
          "default": "bob",
          "required": false
        }
      ],
      "href": "http://localhost:8181/v1/metrics/intel/mock/foo?ver=2"
    }
  }
}

Please note also that if both versions of mock plugin are loaded into snapd, both v1 and v2 metrics are returned by

snapctl metric get -m /intel/mock/*

I think it would be good that this call can be used successfully because there may be cases where user would like to receive all metrics detailed informations at once

@IRCody
Copy link
Contributor

IRCody commented Jul 6, 2016

I went ahead and closed #810 which afaict is about the same issue. This issue has a better description since it points out examples of the API responses.

@mbbroberg
Copy link
Contributor

@IRCody is it cool to label this as a Bug for tracking? I understand @obourdon has a fix in place already.

@IRCody
Copy link
Contributor

IRCody commented Jul 7, 2016

Yes I think that is fine.

tjmcs pushed a commit that referenced this issue Jul 19, 2016
Fix for issue #1048: Invalid API response returned by mock collector
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants