diff --git a/client/client.go b/client/client.go index 1c4d2c6..0e182ec 100644 --- a/client/client.go +++ b/client/client.go @@ -32,10 +32,11 @@ import ( ) type clientConfig struct { - GrpcAddress string `json:"grpc_server_address"` - HttpAddress string `json:"http_server_address"` - StorageRoot string `json:"storage_path"` - MetricNamespace string `json:"metric_namespace"` + GrpcAddress string `json:"grpc_server_address"` + HttpAddress string `json:"http_server_address"` + StorageRoot string `json:"storage_path"` + MetricNamespace string `json:"metric_namespace"` + ConstLabels map[string]string `json:"metric_const_labels"` } func loadClientConfig() (clientConfig, error) { @@ -157,7 +158,7 @@ func gatherDeployedPrograms(storageRoot, name string) (out []*protos.VersionAndA sort.Slice(rawvers, func(i, j int) bool { return rawvers[i].modTime.After(rawvers[j].modTime) }) - + for _, v := range rawvers { out = append(out, v.VersionAndArgs) } diff --git a/client/operation.go b/client/operation.go index 057ada4..b69076d 100644 --- a/client/operation.go +++ b/client/operation.go @@ -213,7 +213,7 @@ func (hc *houstonClient) launch(meta *procmeta) error { return err } - stdReader := func(childProcName string, r io.ReadCloser, index int) { + stdReader := func(jobName string, r io.ReadCloser, index int) { defer func() { reco := recover() if reco != nil { @@ -308,7 +308,12 @@ func (hc *houstonClient) launch(meta *procmeta) error { if desc.ConstLabels == nil { desc.ConstLabels = make(map[string]string) } - desc.ConstLabels["index"] = fmt.Sprintf("%d", index) + + for k, v := range hc.config.ConstLabels { + desc.ConstLabels[k] = v + } + + desc.ConstLabels["job"] = jobName metricExporter.RegisterMetric(&desc) } else { diff --git a/go.mod b/go.mod index 589266f..db9db93 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( golang.org/x/text v0.10.0 google.golang.org/grpc v1.56.0 google.golang.org/protobuf v1.31.0 - repositories.action2quare.com/ayo/gocommon v0.0.0-20240213060646-bef684b3fe34 + repositories.action2quare.com/ayo/gocommon v0.0.0-20240215030631-0c5ddac9f55f ) require ( diff --git a/go.sum b/go.sum index 73c21b5..c2bec2f 100644 --- a/go.sum +++ b/go.sum @@ -173,5 +173,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM= howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= -repositories.action2quare.com/ayo/gocommon v0.0.0-20240213060646-bef684b3fe34 h1:BmcAbve3Ep6FPrdo3XXaIsQlBGt8kAMepmZqrCKkrGw= -repositories.action2quare.com/ayo/gocommon v0.0.0-20240213060646-bef684b3fe34/go.mod h1:Gb418rT96M3K7L/XMPzp8IJj4UXVunq7dZzrxsMBz/8= +repositories.action2quare.com/ayo/gocommon v0.0.0-20240215030631-0c5ddac9f55f h1:ZIDd5JCXlPCVj2656Bqm/yiI0cZzgIa51IOs5AljEAA= +repositories.action2quare.com/ayo/gocommon v0.0.0-20240215030631-0c5ddac9f55f/go.mod h1:Gb418rT96M3K7L/XMPzp8IJj4UXVunq7dZzrxsMBz/8=