VictoriaMetrics/lib/promscrape/discovery/nomad/agent.go
Karan Sharma 8f42c5a024
lib/promscrape: add Prometheus-compatible service discovery for Nomad (#3549)
Add nomad_sd_config support for service discovery
2023-01-05 18:07:02 -08:00

28 lines
541 B
Go

package nomad
import (
"encoding/json"
"fmt"
)
// Agent is Nomad agent.
//
// See https://developer.hashicorp.com/nomad/api-docs/agent
type Agent struct {
Config AgentConfig
}
// AgentConfig is Nomad agent config.
//
// See https://developer.hashicorp.com/nomad/api-docs/agent
type AgentConfig struct {
Datacenter string
}
func parseAgent(data []byte) (*Agent, error) {
var a Agent
if err := json.Unmarshal(data, &a); err != nil {
return nil, fmt.Errorf("cannot unmarshal agent info from %q: %w", data, err)
}
return &a, nil
}