@@ -11,6 +11,7 @@ import (
1111 "context"
1212 "encoding/json"
1313 "fmt"
14+ "github.com/elastic/elastic-agent/pkg/testing/tools/fleettools"
1415 "net/http"
1516 "net/http/httptest"
1617 "net/http/httputil"
@@ -84,7 +85,7 @@ func LogIngestionFleetManaged(t *testing.T, info *define.Info) {
8485
8586 // 2. Install the Elastic-Agent with the policy that
8687 // was just created.
87- policy , _ , err := tools .InstallAgentWithPolicy (
88+ policy , err := tools .InstallAgentWithPolicy (
8889 ctx ,
8990 t ,
9091 installOpts ,
@@ -186,8 +187,6 @@ func testMonitoringLogsAreShipped(
186187 "component %s: want %s, got %s" ,
187188 c .Name , client .Healthy , client .State (c .State ))
188189 }
189- agentID := status .Info .ID
190- t .Logf ("Agent ID: %q" , agentID )
191190
192191 // Stage 3: Make sure there are no errors in logs
193192 t .Log ("Making sure there are no error logs" )
@@ -206,7 +205,6 @@ func testMonitoringLogsAreShipped(
206205 "add_cloud_metadata: received error for provider digitalocean: failed with http status code 404" ,
207206 "add_cloud_metadata: received error for provider azure: failed with http status code 404" ,
208207 "add_cloud_metadata: received error for provider openstack: failed with http status code 404" ,
209- "add_cloud_metadata: received error for provider gcp: failed with http status code 404" ,
210208 "elastic-agent-client error: rpc error: code = Canceled desc = context canceled" , // can happen on restart
211209 "failed to invoke rollback watcher: failed to start Upgrade Watcher" , // on debian this happens probably need to fix.
212210 "falling back to IMDSv1: operation error ec2imds: getToken" , // okay for the cloud metadata to not work
@@ -237,6 +235,16 @@ func testMonitoringLogsAreShipped(
237235 require .NotZero (t , len (docs .Hits .Hits ))
238236
239237 // Stage 4: verify logs from the monitoring components are not sent to the output
238+ t .Log ("Check monitoring logs" )
239+ hostname , err := os .Hostname ()
240+ if err != nil {
241+ t .Fatalf ("could not get hostname to filter Agent: %s" , err )
242+ }
243+
244+ agentID , err := fleettools .GetAgentIDByHostname (ctx , info .KibanaClient , policy .ID , hostname )
245+ require .NoError (t , err , "could not get Agent ID by hostname" )
246+ t .Logf ("Agent ID: %q" , agentID )
247+
240248 // We cannot search for `component.id` because at the moment of writing
241249 // this field is not mapped. There is an issue for that:
242250 // https://github.com/elastic/integrations/issues/6545
0 commit comments