diff --git a/x-pack/plugins/observability_solution/apm/server/routes/environments/get_environments.ts b/x-pack/plugins/observability_solution/apm/server/routes/environments/get_environments.ts index 90ae73a214f4a..e7c5d46e7de10 100644 --- a/x-pack/plugins/observability_solution/apm/server/routes/environments/get_environments.ts +++ b/x-pack/plugins/observability_solution/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/plugins/observability_solution/apm/server/routes/suggestions/get_suggestions_with_terms_aggregation.ts b/x-pack/plugins/observability_solution/apm/server/routes/suggestions/get_suggestions_with_terms_aggregation.ts index 9a2cea0ebf29d..3e646b5e6375b 100644 --- a/x-pack/plugins/observability_solution/apm/server/routes/suggestions/get_suggestions_with_terms_aggregation.ts +++ b/x-pack/plugins/observability_solution/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/apm_api_integration/tests/environment/get_environment.spec.ts b/x-pack/test/apm_api_integration/tests/environment/get_environment.spec.ts index e67c601e7713c..cba6a1e8b6b3b 100644 --- a/x-pack/test/apm_api_integration/tests/environment/get_environment.spec.ts +++ b/x-pack/test/apm_api_integration/tests/environment/get_environment.spec.ts @@ -42,10 +42,10 @@ export default function environmentsAPITests({ getService }: FtrProviderContext) expect(body.environments.length).to.be.equal(4); expectSnapshot(body.environments).toMatchInline(` Array [ + "custom-go-environment", "development", "production", "staging", - "custom-go-environment", ] `); });