Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

The math is not working #7

Closed
ghost opened this issue Jul 29, 2019 · 8 comments
Closed

The math is not working #7

ghost opened this issue Jul 29, 2019 · 8 comments

Comments

@ghost
Copy link

ghost commented Jul 29, 2019

The following configuration returns 0 while each of metric returns valid values:

kind: ExternalMetric
metadata:
  name: elb-request-count-per-instance
spec:
  name: elb-request-count-per-instance
  resource:
    resource: "deployment"
  queries:
    - id: elb_request_count_per_instance
      expression: "elb_external_request_count / elb_external_healthy_host_count"
    - id: elb_external_request_count
      metricLabels: "elb_external_request_count"
      metricStat:
        metric:
          namespace: "AWS/ELB"
          metricName: "RequestCount"
          dimensions:
            - name: LoadBalancerName
              value: "my-load-balancer"
        period: 60
        stat: Sum
        unit: Count
      returnData: false
    - id: elb_external_healthy_host_count
      metricStat:
        metric:
          namespace: "AWS/ELB"
          metricName: "HealthyHostCount"
          dimensions:
            - name: LoadBalancerName
              value: "my-load-balancer"
        period: 60
        stat: Average
        unit: Count
      returnData: false
$ kubectl get --raw  "/apis/external.metrics.k8s.io/v1beta1/namespaces/default/elb-request-count-per-instance" | jq .
{
  "kind": "ExternalMetricValueList",
  "apiVersion": "external.metrics.k8s.io/v1beta1",
  "metadata": {
    "selfLink": "/apis/external.metrics.k8s.io/v1beta1/namespaces/default/elb-request-count-per-instance"
  },
  "items": [
    {
      "metricName": "elb-request-count-per-instance",
      "metricLabels": null,
      "timestamp": "2019-07-29T14:32:46Z",
      "value": "0"
    }
  ]
}
@chankh
Copy link
Contributor

chankh commented Jul 31, 2019

Hi @romansytnik the default value for returnData is false, so for the first query that you have (elb_request_count_per_instance), you will need to specify returnData: true

@ghost
Copy link
Author

ghost commented Aug 1, 2019

@chankh Thanks for the suggestion. In this case, I`m receiving zero as well.
Also I want to pay attention that I need to get the math "elb_external_request_count / elb_external_healthy_host_count" but not the values of any separate two metrics.

@chankh
Copy link
Contributor

chankh commented Aug 6, 2019

you can leave the returnData for the other queries as false and only the one you wish to receive as true

kind: ExternalMetric
metadata:
  name: elb-request-count-per-instance
spec:
  name: elb-request-count-per-instance
  resource:
    resource: "deployment"
  queries:
    - id: elb_request_count_per_instance
      expression: "elb_external_request_count / elb_external_healthy_host_count"
      returnData: true
    - id: elb_external_request_count
      metricLabels: "elb_external_request_count"
      metricStat:
        metric:
          namespace: "AWS/ELB"
          metricName: "RequestCount"
          dimensions:
            - name: LoadBalancerName
              value: "my-load-balancer"
        period: 60
        stat: Sum
        unit: Count
      returnData: false
    - id: elb_external_healthy_host_count
      metricStat:
        metric:
          namespace: "AWS/ELB"
          metricName: "HealthyHostCount"
          dimensions:
            - name: LoadBalancerName
              value: "my-load-balancer"
        period: 60
        stat: Average
        unit: Count
      returnData: false

@ghost
Copy link
Author

ghost commented Aug 12, 2019

I`ve also tried this suggestion as well. Unfortunately, the request returns 0.

{
  "kind": "ExternalMetricValueList",
  "apiVersion": "external.metrics.k8s.io/v1beta1",
  "metadata": {
    "selfLink": "/apis/external.metrics.k8s.io/v1beta1/namespaces/default/elb-request-count-per-instance"
  },
  "items": [
    {
      "metricName": "elb-request-count-per-instance",
      "metricLabels": null,
      "timestamp": "2019-08-12T12:05:15Z",
      "value": "0"
    }
  ]
}

Could it be related to the hardcoded first value which is not always first?
https://github.com/awslabs/k8s-cloudwatch-adapter/blob/v0.4.0/pkg/provider/provider_external.go#L36

@ghost
Copy link
Author

ghost commented Aug 16, 2019

@chankh I`ve checked the PR #9 and as can I see it fixes this issue. When will it be merged?

@chankh
Copy link
Contributor

chankh commented Aug 20, 2019

@romansytnik PR #9 is merged, latest release is v0.6.0

@chankh
Copy link
Contributor

chankh commented Sep 11, 2019

@romansytnik does the latest release solve your issue?

@ghost
Copy link
Author

ghost commented Sep 13, 2019

@chankh yes, this issue is solved now.
Thanks!

@chankh chankh closed this as completed Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant