api: Add Elasticsearch index settings retrieval to application settings

What does this MR do and why?

This change introduces the ability to retrieve Elasticsearch index settings via the application settings API endpoint (GET /api/v4/application/settings). This is necessary to provide users with access to the configuration of Elasticsearch indices, which is essential for managing search capabilities and ensuring deterministic configuration management.

Technical changes:

  • Added elasticsearch_index_settings method to the ApplicationSetting model that returns ordered index settings via the Elastic::IndexSetting.order_by_name scope
  • Created a new Grape API entity API::Entities::Elastic::IndexSetting to expose index attributes with proper documentation:
    • alias_name - Name of the Elasticsearch index alias
    • number_of_shards - Number of shards for the Elasticsearch index
    • number_of_replicas - Number of replicas for the Elasticsearch index
  • Updated the application setting API entity to include the new index settings in the response when the elastic_search license feature is available

Example API response:

{
  "elasticsearch_index_settings": [
    {
      "alias_name": "gitlab-production",
      "number_of_shards": 5,
      "number_of_replicas": 1
    }
  ]
}

🛠️ with ❤️ at Siemens

References

Screenshots or screen recordings

Not applicable - API-only change with no UI modifications.

How to set up and validate locally

  • Enable the Elasticsearch feature license in your development environment
  • Create some Elasticsearch index settings in the database:
    # In rails console
    Elastic::IndexSetting.create!(alias_name: 'test-index', number_of_shards: 5, number_of_replicas: 1)
  • Make an API request to retrieve application settings:
    curl --header "PRIVATE-TOKEN: <your_access_token>" \
         "http://localhost:3000/api/v4/application/settings" | jq '.elasticsearch_index_settings'
  • Verify the response includes the elasticsearch_index_settings array with the expected structure

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

MR Checklist (@gerardo-navarro)

Merge request reports

Loading