diff --git a/internal/nomad/api_querier.go b/internal/nomad/api_querier.go index 408258e..9f51ef3 100644 --- a/internal/nomad/api_querier.go +++ b/internal/nomad/api_querier.go @@ -181,6 +181,9 @@ func (nc *nomadAPIClient) EventStream(ctx context.Context) (<-chan *nomadApi.Eve // As Poseidon uses no such token, the request will return a permission denied error. "*", }, + nomadApi.TopicJob: {"*"}, + nomadApi.TopicNode: {"*"}, + nomadApi.TopicDeployment: {"*"}, }, 0, nc.queryOptions()) diff --git a/internal/nomad/nomad.go b/internal/nomad/nomad.go index 97ceb1a..90c5381 100644 --- a/internal/nomad/nomad.go +++ b/internal/nomad/nomad.go @@ -6,6 +6,7 @@ import ( "fmt" nomadApi "github.com/hashicorp/nomad/api" "github.com/hashicorp/nomad/nomad/structs" + influxdb2 "github.com/influxdata/influxdb-client-go/v2" "github.com/influxdata/influxdb-client-go/v2/api/write" "github.com/openHPI/poseidon/internal/config" "github.com/openHPI/poseidon/pkg/dto" @@ -207,6 +208,7 @@ func (a *APIClient) WatchEventStream(ctx context.Context, callbacks *AllocationP } handler := func(event *nomadApi.Event) (bool, error) { + dumpNomadEventToInflux(event) switch event.Topic { case nomadApi.TopicEvaluation: return false, handleEvaluationEvent(a.evaluations, event) @@ -223,6 +225,15 @@ func (a *APIClient) WatchEventStream(ctx context.Context, callbacks *AllocationP return err } +func dumpNomadEventToInflux(event *nomadApi.Event) { + p := influxdb2.NewPointWithMeasurement(monitoring.MeasurementNomadEvents) + p.AddTag("topic", event.Topic.String()) + p.AddTag("type", event.Type) + p.AddTag("key", event.Key) + p.AddField("payload", event.Payload) + monitoring.WriteInfluxPoint(p) +} + func (a *APIClient) initializeAllocations() { allocationStubs, err := a.listAllocations() if err != nil { diff --git a/pkg/monitoring/influxdb2_middleware.go b/pkg/monitoring/influxdb2_middleware.go index 9f68849..d128f5a 100644 --- a/pkg/monitoring/influxdb2_middleware.go +++ b/pkg/monitoring/influxdb2_middleware.go @@ -23,6 +23,7 @@ const ( // measurementPrefix allows easier filtering in influxdb. measurementPrefix = "poseidon_" measurementPoolSize = measurementPrefix + "poolsize" + MeasurementNomadEvents = measurementPrefix + "nomad_events" MeasurementNomadAllocations = measurementPrefix + "nomad_allocations" MeasurementIdleRunnerNomad = measurementPrefix + "nomad_idle_runners" MeasurementExecutionsAWS = measurementPrefix + "aws_executions"