-
Notifications
You must be signed in to change notification settings - Fork 294
Fix for issue #1048: Invalid API response returned by mock collector #1049
Conversation
Can one of the admins verify this patch? |
@intelsdi-x/snap-maintainers |
I think this invalidates some of the help text for snapctl:
If you load all the mock plugins and do `snapctl metric get -m "/intel/mock/*" I get:
It is returning multiple versions even though the help text says it will default to the latest. Need to change one or the other so they match. I'm also wondering if we want to have separate return messages for a single metric vs multiple metrics. Would it make sense to just always return an array of metrics, which may have one or many metrics? Seems like that would simplify things on both server and client side. |
I think it makes more sense to return an array of metrics since it simplifies both the server and the client. @tjmcs any thoughts? |
@nanliu, I think it's critical to ensure that even in those cases where we are returning multiple metrics by using a wildcard in the From the discussion, above, I think that means the code behind this PR needs to be refactored to ensure that we only get a single value for each metric containing either the latest version or the specified version, not a response containing all versions of all metrics in that namespace. That will ensure that even in those cases where a wildcard is used to retrieve multiple metrics in a given namespace, each of those metrics will match the previous behavior shown by |
@tjmcs please note that as stated in the issue #1048 the current PR only displays what is currently returned by the REST API. Therefore the modification your are requesting to match current behaviour does not mean refactoring current PR code but has to be fixed elsewhere in the code, unless I missed some point of course |
I disagree to a certain extent, @obourdon. The current behavior is the current behavior. If That being said, I am not familiar with this part of the codebase, so I'll have to defer to others as to how |
As an aside, adding support for a query string to the RESTful API (so that the version can be filtered in the RESTful API when a specific version is given) would definitely be helpful (assuming that such support is not already in the RESTful API somewhere, again I'll have to defer to others on this). My assumption here is that the problem is arising when no version is specified, and that in that situation the RESTful API is returning all available versions of a given metric. I'm also assuming (based on the help output for the |
@obourdon, Thanks for your work. I tested this against the latest master, it seems working as expected. The key here is that you get what you requested for. For example:
This PR is good to go if you can address my other comments. |
var merr error | ||
for i, m := range metric.([]*client.GetMetricResult) { | ||
err := printMetric(m, i) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be like this - returns an error if one error occurred instead of waiting to the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your point however why can't we just go through all potential errors and then return instead ?
The only thing this will change is the fact that all errors will be printed at once instead of only one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's cool!
With the merge of PR #1076 I think this PR can now be merged and provide the expected behavior (only showing the latest version when a version number is not specified). 👍 for a merge from me now |
@obourdon, do you mind to make this PR up to date so that we can get this PR merged? thank you. |
@candysmurf will do. However the problem is now that there has been so many changes since I committed this PR, that I have to rework the entire code which I had tested quite extensively. It now does not even compile anymore after merging :-( |
@obourdon, sorry for the inconvenience. I'm looking forward to your update. Thank you. |
@candysmurf in fact it was way less painful than I originally estimated ;-). New version uploaded few hours ago |
@tjmcs please review the last commit. |
Returns all version if no version is specified, updates snapctl help and updates the href to use a parameter for the namespace query.
LGTM, @jcooklin and @obourdon; here's the result of my testing of this PR...first a set of tests run using $ snapctl -u "https://127.0.0.1:12345" --insecure metric list
NAMESPACE VERSIONS
/intel/mock/*/baz 1,2
/intel/mock/bar 1,2
/intel/mock/foo 1,2
$ snapctl -u "https://127.0.0.1:12345" --insecure metric get --metric-namespace '/intel/mock/*'
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/[host]/baz 1 Sun, 31 Dec 0000 16:00:00 PST
Dynamic elements of namespace: /intel/mock/[host]/baz
NAME DESCRIPTION
host name of the host
Rules for collecting /intel/mock/[host]/baz:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/[host]/baz 2 mock unit Tue, 19 Jul 2016 13:16:41 PDT mock description
Dynamic elements of namespace: /intel/mock/[host]/baz
NAME DESCRIPTION
host name of the host
Rules for collecting /intel/mock/[host]/baz:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/bar 1 Sun, 31 Dec 0000 16:00:00 PST
Rules for collecting /intel/mock/bar:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/bar 2 mock unit Tue, 19 Jul 2016 13:16:41 PDT mock description
Rules for collecting /intel/mock/bar:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/foo 1 Sun, 31 Dec 0000 16:00:00 PST
Rules for collecting /intel/mock/foo:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
password string true
name string bob false
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/foo 2 mock unit Tue, 19 Jul 2016 13:16:41 PDT mock description
Rules for collecting /intel/mock/foo:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
name string bob false
password string true
$ snapctl -u "https://127.0.0.1:12345" --insecure metric get --metric-namespace '/intel/mock/foo'
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/foo 1 Sun, 31 Dec 0000 16:00:00 PST
Rules for collecting /intel/mock/foo:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
name string bob false
password string true
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/foo 2 mock unit Tue, 19 Jul 2016 13:16:41 PDT mock description
Rules for collecting /intel/mock/foo:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
name string bob false
password string true
$ snapctl -u "https://127.0.0.1:12345" --insecure metric get --metric-namespace '/intel/mock/*' --metric-version '-1'
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/[host]/baz 2 mock unit Tue, 19 Jul 2016 13:16:41 PDT mock description
Dynamic elements of namespace: /intel/mock/[host]/baz
NAME DESCRIPTION
host name of the host
Rules for collecting /intel/mock/[host]/baz:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/bar 2 mock unit Tue, 19 Jul 2016 13:16:41 PDT mock description
Rules for collecting /intel/mock/bar:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/foo 2 mock unit Tue, 19 Jul 2016 13:16:41 PDT mock description
Rules for collecting /intel/mock/foo:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
name string bob false
password string true
$ snapctl -u "https://127.0.0.1:12345" --insecure metric get --metric-namespace '/intel/mock/*' --metric-version '0'
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/[host]/baz 1 Sun, 31 Dec 0000 16:00:00 PST
Dynamic elements of namespace: /intel/mock/[host]/baz
NAME DESCRIPTION
host name of the host
Rules for collecting /intel/mock/[host]/baz:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/[host]/baz 2 mock unit Tue, 19 Jul 2016 13:16:41 PDT mock description
Dynamic elements of namespace: /intel/mock/[host]/baz
NAME DESCRIPTION
host name of the host
Rules for collecting /intel/mock/[host]/baz:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/bar 1 Sun, 31 Dec 0000 16:00:00 PST
Rules for collecting /intel/mock/bar:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/bar 2 mock unit Tue, 19 Jul 2016 13:16:41 PDT mock description
Rules for collecting /intel/mock/bar:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/foo 1 Sun, 31 Dec 0000 16:00:00 PST
Rules for collecting /intel/mock/foo:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
name string bob false
password string true
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/foo 2 mock unit Tue, 19 Jul 2016 13:16:41 PDT mock description
Rules for collecting /intel/mock/foo:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
name string bob false
password string true
$ snapctl -u "https://127.0.0.1:12345" --insecure metric get --metric-namespace '/intel/mock/*' --metric-version '1'
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/[host]/baz 1 Sun, 31 Dec 0000 16:00:00 PST
Dynamic elements of namespace: /intel/mock/[host]/baz
NAME DESCRIPTION
host name of the host
Rules for collecting /intel/mock/[host]/baz:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/bar 1 Sun, 31 Dec 0000 16:00:00 PST
Rules for collecting /intel/mock/bar:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/foo 1 Sun, 31 Dec 0000 16:00:00 PST
Rules for collecting /intel/mock/foo:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
name string bob false
password string true
$ snapctl -u "https://127.0.0.1:12345" --insecure metric get --metric-namespace '/intel/mock/*' --metric-version '3'
$ snapctl -u "https://127.0.0.1:12345" --insecure metric get --metric-namespace '/intel/mock/foo' --metric-version '-1'
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/foo 2 mock unit Tue, 19 Jul 2016 13:16:41 PDT mock description
Rules for collecting /intel/mock/foo:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
name string bob false
password string true
$ snapctl -u "https://127.0.0.1:12345" --insecure metric get --metric-namespace '/intel/mock/foo' --metric-version '0'
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/foo 1 Sun, 31 Dec 0000 16:00:00 PST
Rules for collecting /intel/mock/foo:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
name string bob false
password string true
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/foo 2 mock unit Tue, 19 Jul 2016 13:16:41 PDT mock description
Rules for collecting /intel/mock/foo:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
password string true
name string bob false
$ snapctl -u "https://127.0.0.1:12345" --insecure metric get --metric-namespace '/intel/mock/foo' --metric-version '1'
NAMESPACE VERSION UNIT LAST ADVERTISED TIME DESCRIPTION
/intel/mock/foo 1 Sun, 31 Dec 0000 16:00:00 PST
Rules for collecting /intel/mock/foo:
NAME TYPE DEFAULT REQUIRED MINIMUM MAXIMUM
name string bob false
password string true
$ snapctl -u "https://127.0.0.1:12345" --insecure metric get --metric-namespace '/intel/mock/foo' --metric-version '3'
$ and then this equivalent set of curl commands (each correspondiing to one of to the $ curl -k "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2F*"
{
"meta": {
"code": 200,
"message": "Metrics returned",
"type": "metrics_returned",
"version": 1
},
"body": [
{
"last_advertised_timestamp": -62135596800,
"namespace": "/intel/mock/*/baz",
"version": 1,
"dynamic": true,
"dynamic_elements": [
{
"index": 2,
"name": "host",
"description": "name of the host"
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2F%2A%2Fbaz&ver=1"
},
{
"last_advertised_timestamp": 1468959401,
"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": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2F%2A%2Fbaz&ver=2"
},
{
"last_advertised_timestamp": -62135596800,
"namespace": "/intel/mock/bar",
"version": 1,
"dynamic": false,
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Fbar&ver=1"
},
{
"last_advertised_timestamp": 1468959401,
"namespace": "/intel/mock/bar",
"version": 2,
"dynamic": false,
"description": "mock description",
"unit": "mock unit",
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Fbar&ver=2"
},
{
"last_advertised_timestamp": -62135596800,
"namespace": "/intel/mock/foo",
"version": 1,
"dynamic": false,
"policy": [
{
"name": "name",
"type": "string",
"default": "bob",
"required": false
},
{
"name": "password",
"type": "string",
"default": "",
"required": true
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=1"
},
{
"last_advertised_timestamp": 1468959401,
"namespace": "/intel/mock/foo",
"version": 2,
"dynamic": false,
"description": "mock description",
"unit": "mock unit",
"policy": [
{
"name": "name",
"type": "string",
"default": "bob",
"required": false
},
{
"name": "password",
"type": "string",
"required": true
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=2"
}
]
}%
$ curl -k "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo"
{
"meta": {
"code": 200,
"message": "Metrics returned",
"type": "metrics_returned",
"version": 1
},
"body": [
{
"last_advertised_timestamp": -62135596800,
"namespace": "/intel/mock/foo",
"version": 1,
"dynamic": false,
"policy": [
{
"name": "name",
"type": "string",
"default": "bob",
"required": false
},
{
"name": "password",
"type": "string",
"default": "",
"required": true
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=1"
},
{
"last_advertised_timestamp": 1468959401,
"namespace": "/intel/mock/foo",
"version": 2,
"dynamic": false,
"description": "mock description",
"unit": "mock unit",
"policy": [
{
"name": "name",
"type": "string",
"default": "bob",
"required": false
},
{
"name": "password",
"type": "string",
"required": true
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=2"
}
]
}%
$ curl -k "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2F*&ver=-1"
{
"meta": {
"code": 200,
"message": "Metrics returned",
"type": "metrics_returned",
"version": 1
},
"body": [
{
"last_advertised_timestamp": 1468959401,
"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": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2F%2A%2Fbaz&ver=2"
},
{
"last_advertised_timestamp": 1468959401,
"namespace": "/intel/mock/bar",
"version": 2,
"dynamic": false,
"description": "mock description",
"unit": "mock unit",
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Fbar&ver=2"
},
{
"last_advertised_timestamp": 1468959401,
"namespace": "/intel/mock/foo",
"version": 2,
"dynamic": false,
"description": "mock description",
"unit": "mock unit",
"policy": [
{
"name": "name",
"type": "string",
"default": "bob",
"required": false
},
{
"name": "password",
"type": "string",
"required": true
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=2"
}
]
}%
$ curl -k "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2F*&ver=0"
{
"meta": {
"code": 200,
"message": "Metrics returned",
"type": "metrics_returned",
"version": 1
},
"body": [
{
"last_advertised_timestamp": -62135596800,
"namespace": "/intel/mock/*/baz",
"version": 1,
"dynamic": true,
"dynamic_elements": [
{
"index": 2,
"name": "host",
"description": "name of the host"
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2F%2A%2Fbaz&ver=1"
},
{
"last_advertised_timestamp": 1468959401,
"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": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2F%2A%2Fbaz&ver=2"
},
{
"last_advertised_timestamp": -62135596800,
"namespace": "/intel/mock/bar",
"version": 1,
"dynamic": false,
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Fbar&ver=1"
},
{
"last_advertised_timestamp": 1468959401,
"namespace": "/intel/mock/bar",
"version": 2,
"dynamic": false,
"description": "mock description",
"unit": "mock unit",
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Fbar&ver=2"
},
{
"last_advertised_timestamp": -62135596800,
"namespace": "/intel/mock/foo",
"version": 1,
"dynamic": false,
"policy": [
{
"name": "name",
"type": "string",
"default": "bob",
"required": false
},
{
"name": "password",
"type": "string",
"default": "",
"required": true
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=1"
},
{
"last_advertised_timestamp": 1468959401,
"namespace": "/intel/mock/foo",
"version": 2,
"dynamic": false,
"description": "mock description",
"unit": "mock unit",
"policy": [
{
"name": "name",
"type": "string",
"default": "bob",
"required": false
},
{
"name": "password",
"type": "string",
"required": true
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=2"
}
]
}%
$ curl -k "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2F*&ver=1"
{
"meta": {
"code": 200,
"message": "Metrics returned",
"type": "metrics_returned",
"version": 1
},
"body": [
{
"last_advertised_timestamp": -62135596800,
"namespace": "/intel/mock/*/baz",
"version": 1,
"dynamic": true,
"dynamic_elements": [
{
"index": 2,
"name": "host",
"description": "name of the host"
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2F%2A%2Fbaz&ver=1"
},
{
"last_advertised_timestamp": -62135596800,
"namespace": "/intel/mock/bar",
"version": 1,
"dynamic": false,
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Fbar&ver=1"
},
{
"last_advertised_timestamp": -62135596800,
"namespace": "/intel/mock/foo",
"version": 1,
"dynamic": false,
"policy": [
{
"name": "password",
"type": "string",
"default": "",
"required": true
},
{
"name": "name",
"type": "string",
"default": "bob",
"required": false
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=1"
}
]
}%
$ curl -k "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2F*&ver=3"
{
"meta": {
"code": 200,
"message": "Metrics returned",
"type": "metrics_returned",
"version": 1
},
"body": []
}%
$ curl -k "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=-1"
{
"meta": {
"code": 200,
"message": "Metrics returned",
"type": "metrics_returned",
"version": 1
},
"body": [
{
"last_advertised_timestamp": 1468959401,
"namespace": "/intel/mock/foo",
"version": 2,
"dynamic": false,
"description": "mock description",
"unit": "mock unit",
"policy": [
{
"name": "name",
"type": "string",
"default": "bob",
"required": false
},
{
"name": "password",
"type": "string",
"required": true
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=2"
}
]
}%
$ curl -k "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=0"
{
"meta": {
"code": 200,
"message": "Metrics returned",
"type": "metrics_returned",
"version": 1
},
"body": [
{
"last_advertised_timestamp": -62135596800,
"namespace": "/intel/mock/foo",
"version": 1,
"dynamic": false,
"policy": [
{
"name": "name",
"type": "string",
"default": "bob",
"required": false
},
{
"name": "password",
"type": "string",
"default": "",
"required": true
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=1"
},
{
"last_advertised_timestamp": 1468959401,
"namespace": "/intel/mock/foo",
"version": 2,
"dynamic": false,
"description": "mock description",
"unit": "mock unit",
"policy": [
{
"name": "name",
"type": "string",
"default": "bob",
"required": false
},
{
"name": "password",
"type": "string",
"required": true
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=2"
}
]
}%
$ curl -k "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=1"
{
"meta": {
"code": 200,
"message": "Metrics returned",
"type": "metrics_returned",
"version": 1
},
"body": [
{
"last_advertised_timestamp": -62135596800,
"namespace": "/intel/mock/foo",
"version": 1,
"dynamic": false,
"policy": [
{
"name": "name",
"type": "string",
"default": "bob",
"required": false
},
{
"name": "password",
"type": "string",
"default": "",
"required": true
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=1"
}
]
}%
$ curl -k "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=3"
{
"meta": {
"code": 200,
"message": "Metrics returned",
"type": "metrics_returned",
"version": 1
},
"body": []
}%
$ curl -k "https://127.0.0.1:12345/v1/metrics/intel/mock/foo?ver=-1"
{
"meta": {
"code": 200,
"message": "Metric returned",
"type": "metric_returned",
"version": 1
},
"body": {
"Metric": {
"last_advertised_timestamp": 1468959401,
"namespace": "/intel/mock/foo",
"version": 2,
"dynamic": false,
"description": "mock description",
"unit": "mock unit",
"policy": [
{
"name": "name",
"type": "string",
"default": "bob",
"required": false
},
{
"name": "password",
"type": "string",
"required": true
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=2"
}
}
}%
$ curl -k "https://127.0.0.1:12345/v1/metrics/intel/mock/*?ver=-1"
{
"meta": {
"code": 200,
"message": "Metrics returned",
"type": "metrics_returned",
"version": 1
},
"body": [
{
"last_advertised_timestamp": 1468959401,
"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": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2F%2A%2Fbaz&ver=2"
},
{
"last_advertised_timestamp": 1468959401,
"namespace": "/intel/mock/bar",
"version": 2,
"dynamic": false,
"description": "mock description",
"unit": "mock unit",
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Fbar&ver=2"
},
{
"last_advertised_timestamp": 1468959401,
"namespace": "/intel/mock/foo",
"version": 2,
"dynamic": false,
"description": "mock description",
"unit": "mock unit",
"policy": [
{
"name": "name",
"type": "string",
"default": "bob",
"required": false
},
{
"name": "password",
"type": "string",
"required": true
}
],
"href": "https://127.0.0.1:12345/v1/metrics?ns=%2Fintel%2Fmock%2Ffoo&ver=2"
}
]
}%
$ As I said, I'm now seeing consistent behavior across all of these various ways of obtaining the list of metrics, both with and without a wildcard in the metric namespace value so I think this PR is finally ready for a merge. Not only that, but now that we've removed the inconsistencies in what was returned when the version was set to |
Fixes #1048
Summary of changes:
Testing done:
@intelsdi-x/snap-maintainers