Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

single vs plural noun for metric types #42

Open
vnugent opened this issue Mar 15, 2017 · 2 comments
Open

single vs plural noun for metric types #42

vnugent opened this issue Mar 15, 2017 · 2 comments

Comments

@vnugent
Copy link

vnugent commented Mar 15, 2017

When introspecting metric definition the Python client returns metric type of (in json) counter, gauge or string (single noun). If I want to build dynamic query to fetch metric data based on the returned definition I would have convert the returned type gauge into MetricType.Gauge whose string representation is gauges (plural). It would be convenient to pass the same returned type to query_metric(type, metric_id).

@vnugent
Copy link
Author

vnugent commented Mar 15, 2017

from hawkular.metrics import HawkularMetricsClient, MetricType

host = 'hawkular-services-openshift-infra.origin.cloud1.hawkular.org'
path = 'hawkular/metrics'
port = '443'
token = 'paste_real_token_here'
tenant_id='promgen'

if __name__ == "__main__":
    client = HawkularMetricsClient(token=token, tenant_id=tenant_id, scheme='https', host=host, path=path, port=port)
    definition = client.query_metric_definitions(custom_metric='true')
    # print metric id and type. 
    # fetch actual  data from the first counter metric
    for item in definition:
        metric_type = item['type']
        metric_id = item['id']
        print "id: {}, item: {}".format(metric_id, metric_type)
        if metric_type == 'counter':
            # it would be nice if we can pass metric_type directly to query_metric()
            # data = client.query_metric(metric_type, metric_id);
            data = client.query_metric(MetricType.Counter, metric_id);
            print data
            break

@burmanm
Copy link
Contributor

burmanm commented Mar 16, 2017

Solved best with #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants