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 1eeb03087396a..cbe66eac30e33 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 @@ -55,6 +55,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 ad33634726249..37468543dd813 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 @@ -52,7 +52,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", ] `); });