diff --git a/x-pack/solutions/observability/plugins/apm/server/routes/environments/get_environments.ts b/x-pack/solutions/observability/plugins/apm/server/routes/environments/get_environments.ts index 816be5a8652f1..30cd900f08897 100644 --- a/x-pack/solutions/observability/plugins/apm/server/routes/environments/get_environments.ts +++ b/x-pack/solutions/observability/plugins/apm/server/routes/environments/get_environments.ts @@ -54,6 +54,7 @@ export async function getEnvironments({ terms: { field: SERVICE_ENVIRONMENT, missing: ENVIRONMENT_NOT_DEFINED.value, + order: { _key: 'asc' as const }, size, }, }, diff --git a/x-pack/solutions/observability/plugins/apm/server/routes/suggestions/get_suggestions_with_terms_aggregation.ts b/x-pack/solutions/observability/plugins/apm/server/routes/suggestions/get_suggestions_with_terms_aggregation.ts index cdf8296d37653..f9d36ca0f1f0c 100644 --- a/x-pack/solutions/observability/plugins/apm/server/routes/suggestions/get_suggestions_with_terms_aggregation.ts +++ b/x-pack/solutions/observability/plugins/apm/server/routes/suggestions/get_suggestions_with_terms_aggregation.ts @@ -51,7 +51,11 @@ export async function getSuggestionsWithTermsAggregation({ }, aggs: { items: { - terms: { field: fieldName, size }, + terms: { + field: fieldName, + size, + order: { _key: 'asc' as const }, + }, }, }, }); diff --git a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/environment/get_environment.spec.ts b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/environment/get_environment.spec.ts index ba6f0df98e3a1..bc3d95e42cadc 100644 --- a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/environment/get_environment.spec.ts +++ b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/environment/get_environment.spec.ts @@ -104,10 +104,10 @@ export default function environmentsAPITests({ getService }: DeploymentAgnosticF expect(body.environments.length).to.be.equal(4); expectSnapshot(body.environments).toMatchInline(` Array [ + "custom-go-environment", "development", "production", "staging", - "custom-go-environment", ] `); });