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

fix(): Add pod_name label to slicegw_latency metrics #39

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pkg/metrics/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
)

//create latency metrics which has to be populated when we receive latency from tunnel
// create latency metrics which has to be populated when we receive latency from tunnel
var (
podName = os.Getenv("HOSTNAME")
narmidm marked this conversation as resolved.
Show resolved Hide resolved
sourceClusterId = os.Getenv("CLUSTER_ID")
remoteClusterId = os.Getenv("REMOTE_CLUSTER_ID")
remoteGatewayId = os.Getenv("REMOTE_GATEWAY_ID")
sourceGatewayId = os.Getenv("GATEWAY_ID")
sliceName = os.Getenv("SLICE_NAME")
namespace = "kubeslice_system"
constlabels = prometheus.Labels{
"pod_name": podName,
"slice_name": sliceName,
"source_slice_cluster_id": sourceClusterId,
"remote_slice_cluster_id": remoteClusterId,
Expand All @@ -50,7 +52,7 @@ var (
log *logger.Logger = logger.NewLogger()
)

//common method get gauge metrics alongwith labels
// common method get gauge metrics alongwith labels
func getGaugeMetrics(name string, help string) prometheus.Gauge {
return prometheus.NewGauge(
prometheus.GaugeOpts{
Expand All @@ -61,7 +63,7 @@ func getGaugeMetrics(name string, help string) prometheus.Gauge {
})
}

//method to register metrics to prometheus
// method to register metrics to prometheus
func StartMetricsCollector(metricCollectorPort string) {
metricCollectorPort = ":" + metricCollectorPort
log.Infof("Starting metric collector @ %s", metricCollectorPort)
Expand All @@ -86,7 +88,7 @@ func StartMetricsCollector(metricCollectorPort string) {
log.Info("Started Prometheus server at", metricCollectorPort)
}

//send http request
// send http request
func newHandlerWithHistogram(handler http.Handler, histogram *prometheus.HistogramVec) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
start := time.Now()
Expand Down
1 change: 0 additions & 1 deletion pkg/sidecar/sidecarpb/gw_sidecar.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/sidecar/sidecarpb/gw_sidecar_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ func getGwPodStatus() (*GwPodStatus, error) {
if statusMonitor != nil {
// Get the monitor status checks
checks := statusMonitor.Checks()
log.Info("checks","checks",checks)
log.Info("checks", "checks", checks)
for _, v := range checks {
stats, err := v.Status()
log.Info("stats","stats ",stats)
log.Info("stats", "stats ", stats)
if err != nil {
// this means that tunnel is not established
tunnelStatus.Status = TunnelStatusType_GW_TUNNEL_STATE_DOWN
podStatus.TunnelStatus = &tunnelStatus
log.Infof("pod status : %v", podStatus)
return podStatus,nil
return podStatus, nil
}
tunnelStatus = TunnelInterfaceStatus{
NetInterface: stats.NetInterface,
Expand Down