Skip to content

Commit

Permalink
Remove timestamp from proto
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivaka committed Mar 18, 2024
1 parent 20be248 commit f8af4a9
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 146 deletions.
2 changes: 1 addition & 1 deletion charts/gpu-metrics-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
{{- end }}
labels:
{{- include "gpu-metrics-exporter.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
Expand Down
2 changes: 1 addition & 1 deletion charts/gpu-metrics-exporter/values.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
image:
repository: ghcr.io/castai/gpu-metrics-exporter/gpu-metrics-exporter
pullPolicy: IfNotPresent
tag: "0e167c680f7959b42e40e8d540445417f833c433"
tag: "ed2a4826feaa20bc1f928593f98272fe7e208c9a"

imagePullSecrets:
- name: dockerconfigjson-github-com
Expand Down
5 changes: 2 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import (
type Config struct {
HTTPListenPort int `envconfig:"HTTP_LISTEN_PORT" default:"6061"`
LogLevel string `envconfig:"LOG_LEVEL" default:"info"`
KubeConfigPath string `envconfig:"KUBE_CONFIG_PATH"`
DCGMLabels map[string]string `envconfig:"DCGM_LABELS" default:"app.kubernetes.io/component:dcgm-exporter"`
KubeConfigPath string `envconfig:"KUBE_CONFIG_PATH" default:"/Users/ivaylopapratilov/.kube/config"`
DCGMLabels map[string]string `envconfig:"DCGM_LABELS" default:"app.kubernetes.io/name:dcgm-exporter"`
DCGMPort int `envconfig:"DCGM_PORT" default:"9400"`
DCGMMetricsEndpoint string `envconfig:"DCGM_METRICS_ENDPOINT" default:"/metrics"`
ExportInterval time.Duration `envconfig:"EXPORT_INTERVAL" default:"15s"`
CastAPI string `envconfig:"CAST_API" default:"https://api.cast.ai"`
APIToken string `envconfig:"API_TOKEN"`
ClusterID string `envconfig:"CLUSTER_ID"`
APIKey string `envconfig:"API_KEY"`
}
Expand Down
10 changes: 2 additions & 8 deletions internal/exporter/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package exporter
import (
"time"

"google.golang.org/protobuf/types/known/timestamppb"

"github.com/castai/gpu-metrics-exporter/pb"
)

Expand Down Expand Up @@ -37,12 +35,9 @@ func (p metricMapper) Map(metricFamilyMaps []MetricFamilyMap, ts time.Time) *pb.
}
t := family.Type.String()
for _, m := range family.Metric {
labels := []*pb.Metric_Label{}
labels := make(map[string]string)
for _, l := range m.Label {
labels = append(labels, &pb.Metric_Label{
Name: *l.Name,
Value: *l.Value,
})
labels[*l.Name] = *l.Value
}
var newValue float64
switch t {
Expand All @@ -54,7 +49,6 @@ func (p metricMapper) Map(metricFamilyMaps []MetricFamilyMap, ts time.Time) *pb.

metric.Measurements = append(metric.Measurements, &pb.Metric_Measurement{
Value: newValue,
Ts: timestamppb.New(ts),
Labels: labels,
})
}
Expand Down
6 changes: 2 additions & 4 deletions internal/exporter/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

dto "github.com/prometheus/client_model/go"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/castai/gpu-metrics-exporter/internal/exporter"
"github.com/castai/gpu-metrics-exporter/pb"
Expand Down Expand Up @@ -101,9 +100,8 @@ func TestMetricMapper_Map(t *testing.T) {
Measurements: []*pb.Metric_Measurement{
{
Value: 1.0,
Ts: timestamppb.New(ts),
Labels: []*pb.Metric_Label{
{Name: "label1", Value: "value1"},
Labels: map[string]string{
"label1": "value1",
},
},
},
Expand Down
159 changes: 39 additions & 120 deletions pb/metrics.pb.go

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

11 changes: 2 additions & 9 deletions pb/metrics.proto
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
syntax = "proto3";

import "google/protobuf/timestamp.proto";

option go_package = "github.com/castai/gpu-metrics-exporter/pb";


message Metric {
string name = 1;
repeated Measurement measurements = 2;

message Label {
string name = 1;
string value = 2;
}

message Measurement {
double value = 1;
google.protobuf.Timestamp ts = 2;
repeated Label labels = 3;
map<string, string> labels = 2;
}
}

Expand Down

0 comments on commit f8af4a9

Please sign in to comment.