diff --git a/api/agent.go b/api/agent.go index 50d0aebd..1275d601 100644 --- a/api/agent.go +++ b/api/agent.go @@ -3,4 +3,7 @@ package api // AgentMetadata is metadata about the agent. type AgentMetadata struct { Version string `json:"version"` + // ClusterID is the name of the cluster or host where the agent is running. + // It may send data for other clusters in its datareadings. + ClusterID string `json:"cluster_id"` } diff --git a/api/datareading.go b/api/datareading.go index 495c69f1..b08444e9 100644 --- a/api/datareading.go +++ b/api/datareading.go @@ -1,9 +1,13 @@ package api +import "time" + // DataReadingsPost is the payload in the upload request. type DataReadingsPost struct { AgentMetadata *AgentMetadata `json:"agent_metadata"` - DataReadings []*DataReading `json:"data_readings"` + // DataGatherTime represents the time that the data readings were gathered + DataGatherTime time.Time `json:"data_gather_time"` + DataReadings []*DataReading `json:"data_readings"` } // DataReading is the output of a DataGatherer. diff --git a/pkg/agent/run.go b/pkg/agent/run.go index 70546e6c..092097c5 100644 --- a/pkg/agent/run.go +++ b/pkg/agent/run.go @@ -108,7 +108,8 @@ func getConfiguration(ctx context.Context) (Config, *client.PreflightClient) { } agentMetadata := &api.AgentMetadata{ - Version: version.PreflightVersion, + Version: version.PreflightVersion, + ClusterID: config.ClusterID, } var preflightClient *client.PreflightClient if credentials != nil { diff --git a/pkg/client/client.go b/pkg/client/client.go index 1ee1a98a..d001b385 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -6,6 +6,7 @@ import ( "fmt" "io/ioutil" "path/filepath" + "time" "github.com/jetstack/preflight/api" ) @@ -77,8 +78,9 @@ func (c *PreflightClient) usingOAuth2() bool { // PostDataReadings sends a slice of readings to Preflight. func (c *PreflightClient) PostDataReadings(orgID string, readings []*api.DataReading) error { payload := api.DataReadingsPost{ - AgentMetadata: c.agentMetadata, - DataReadings: readings, + AgentMetadata: c.agentMetadata, + DataGatherTime: time.Now().UTC(), + DataReadings: readings, } data, err := json.Marshal(payload) if err != nil {