kubecost / features-bugs

A public repository for filing of Kubecost feature requests and bugs. Please read the issue guidelines before filing an issue here.
0 stars 0 forks source link

[Bug] Network cost query label #45

Open KKHYeon opened 7 months ago

KKHYeon commented 7 months ago

Kubecost Helm Chart Version

1.108.1

Kubernetes Version

1.28

Kubernetes Platform

EKS

Description

In the Cost Analyzer pod, when querying related to network costs, it uses the ‘sameRegion/sameZone’ label for the query. However, the actual metrics collected are set and collected as ‘same_region/same_zone’. This could potentially lead to discrepancies or issues due to the difference in label naming conventions used in querying and data collection.

Steps to reproduce

  1. in cost-analyzer pod log
    sum(increase(kubecost_pod_network_egress_bytes_total{internet="false", sameZone="false", sameRegion="false", cluster="..."}[2m] )) by (namespace,pod_name,cluster) / 1024 / 1024 / 1024
  2. network costs actual metrics
    kubecost_pod_network_egress_bytes_total{pod_name="...",namespace="kube-system",internet="true",same_region="false",same_zone="false",service=""}

Expected behavior

Cost Analyzer pod should use the same labels.

Impact

No response

Screenshots

No response

Logs

No response

Slack discussion

No response

Troubleshooting

chipzoller commented 7 months ago

@thomasvn, is this a Helm issue or something else?

thomasvn commented 7 months ago

@KKHYeon @chipzoller Thanks for pointing out the issue! This seems to be a bug in the cost-model logic, as opposed to the Helm chart.

chipzoller commented 7 months ago

Thanks, Thomas. Transferred to the features-bugs repository.

thomasvn commented 7 months ago

This is one location in the code, that matches the incorrect labels you point out. However, git blame shows that these lines haven't been modified in ~8months. It's possible that these labels changed when network-costs moved from a Go based image, to a Rust based image. cc @mbolt35

https://github.com/opencost/opencost/blob/9b43b493563e1b87f023b22fdf2fbe0ae25e06c2/pkg/costmodel/costmodel.go#L236-L238

KKHYeon commented 7 months ago

Thank you for your response!

mbolt35 commented 7 months ago

This issue seems related to the move to rust. The rust prom metric writer is likely just leveraging the internal struct field names (which use the _ naming... go used the camel casing).

This is a great catch, and thankfully an easy fix. Thanks for flagging me down @thomasvn - this one is definitely on me!

Also, to be clear, this is what I would consider a major feature breaking bug. I'm going to address this and release 0.17.3 ASAP, likely followed by a helm chart update.

mbolt35 commented 7 months ago

This should be resolved with: https://github.com/opencost/opencost/pull/2478