AWS Big Data Blog
Set advanced settings with the Amazon OpenSearch Service Dashboards API
Amazon OpenSearch Service is a fully managed service that you can use to deploy and operate OpenSearch clusters cost-effectively at scale in the AWS Cloud. The service makes it easy for you to perform interactive log analytics, real-time application monitoring, website search, and more by offering the latest versions of OpenSearch, support for 19 versions of Elasticsearch (1.5 to 7.10 versions), and visualization capabilities powered by OpenSearch Dashboards and Kibana (1.5 to 7.10 versions).
A common use case of OpenSearch in multi-tenant environments is to use tenants in OpenSearch Dashboards and provide segregated index patterns, dashboards, and visualizations to different teams in the organization. Tenants in OpenSearch Dashboards aren’t the same as indexes, where OpenSearch organizes all data. You may still have multiple indexes for multi-tenancy and tenants for controlling access to OpenSearch Dashboards’ saved objects.
In this post, we focus on operationalizing advanced settings for OpenSearch Dashboards tenants with programmatic ways, in particular with the Dashboards Advanced Settings API. For a deeper insight into multi-tenancy in OpenSearch, refer to OpenSearch Dashboards multi-tenancy.
One example of advanced settings configurations is deploying time zone settings in an environment where each tenant is aligned to a different geographic area with specific time zone. We explain the time zone configuration with the UI and demonstrate configuring it with the OpenSearch Dashboards Advanced Settings API using curl. This post also provides guidance for other advanced settings you may wish to include in your deployment.
To follow along in this post, make sure you have an Amazon OpenSearch Service domain with access to OpenSearch Dashboards through a role with administrator privileges for the domain. For more information about enabling access control mechanisms for your domains, see Fine-grained access control in Amazon OpenSearch Service.
The following examples use Amazon OpenSearch Service version 1.0, which was the latest release at the time of writing.
Configure advanced settings in the OpenSearch Dashboards UI
To configure advanced settings via the OpenSearch Dashboards UI, complete the following steps:
- Log in to OpenSearch Dashboards.
- Choose your user icon and choose Switch Tenants to choose the tenant you want to change configuration for.
By default, all OpenSearch Dashboards users have access to two tenants: private and global. The global tenant is shared between every OpenSearch Dashboards user. The private tenant is exclusive to each user and used mostly for experimenting before publishing configuration to other tenants. Make sure to check your configurations in the private tenant before replicating in other tenants, including global.
- Choose Stack Management in the navigation pane, then choose Advanced Settings.
- In your desired tenant context, choose a value for Timezone for date formatting.
In this example, we change the time zone from the default selection Browser to US/Eastern.
Configure advanced settings with the OpenSearch Dashboards API
For environments where you prefer to perform operations programmatically, Amazon OpenSearch Service provides the ability to configure advanced settings with the OpenSearch Dashboards advanced settings API.
Let’s walk through configuring the time zone using curl.
- First, you need to authenticate to the API endpoint with your user name and password, and retrieve the authorization cookies into the file
auth.txt
:
In this example, we configure OpenSearch Dashboards to use the internal user database, and the user inherits administrative permissions under the global tenant. In multi-tenant environments, the user is required to have relevant tenant permissions. You can see an example of this in the next section, where we illustrate a multi-tenant environment. Access control in OpenSearch Dashboards is a broad and important topic, and it would be unfair to try to squeeze all of it in this post. Therefore, we don’t cover access control in depth here. For additional information on access control in multi-tenant OpenSearch Dashboards, refer to OpenSearch Dashboards multi-tenancy.
The auth.txt
file holds authorization cookies that you use to pass configuration changes to the API endpoint. The auth.txt
file should look similar to the following code:
- Construct configuration changes within the curl body and submit them using an authorization cookie. In this example, we included a sample to modify the time zone to
US/Eastern
.
By default, the constructed API modifies the configuration in the private tenant, which is exclusive to each user, can’t be shared, and is ideal for testing. We provide instructions to modify configuration in multi-tenant environments later in the post.
Your API call should receive a response similar to the following code, indicating the changes you submitted:
If you prefer to make multiple changes, you can construct the API call as follows:
To retrieve the latest configuration changes, construct a GET request as follows:
Configure advanced settings with the OpenSearch Dashboards API in multi-tenant environments
Tenants in OpenSearch Dashboards are commonly used to share custom index patterns, visualizations, dashboards, and other OpenSearch objects with different teams or organizations.
The OpenSearch Dashboards API provides the ability to modify advanced settings in different tenants. In the previous section, we covered making advanced configuration changes for a private tenant. We now walk through a similar scenario for multiple tenants.
- First, you need to authenticate to the API endpoint and retrieve the authorization cookies into the file
auth.txt
. You can construct this request in the same way you would in a single-tenant environment as described in the previous section.
In multi-tenant environments, make sure you configure the user’s role with relevant tenant permissions. One pattern is to associate the user to the kibana_user
and a custom group that has tenant permissions. In our example, we associated the tenant admin user tenant-a_admin_user
to the two roles as shown in the following code: the kibana_user
system role and a custom tenant-a_admin_role
that includes tenant permissions.
After authenticating to the OpenSearch Dashboards API, the auth.txt
file holds authorization cookies that you use to pass configuration changes to the API endpoint. The content of the auth.txt
file should be similar to the one we illustrated in the previous section.
- Construct the configuration changes by adding a
securitytenant
header. In this example, we modify the time zone and day of week in tenant-a:
The OpenSearch Dashboards API endpoint returns a response similar to the following:
You could also verify the configuration changes in the OpenSearch Dashboards UI, as shown in the following screenshot.
Conclusion
In this post, you used the Amazon OpenSearch Service Dashboards UI and API to configure advanced settings for a single-tenant and multi-tenant environment. Implementing OpenSearch Dashboards at scale in multi-tenant environments requires more efficient methods than simply using the UI. This is especially important in environments where you serve centralized logging and monitoring domains for different teams. You can use the OpenSearch Dashboards APIs we illustrated in this post and bake your advanced setting configurations into your infrastructure code to accelerate your deployments!
Let us know about your questions and other topics you’d like us to cover in the comment section.
About the Authors
Prashant Agrawal is a Specialist Solutions Architect at Amazon Web Services based in Seattle, WA.. Prashant works closely with Amazon OpenSearch team, helping customers migrate their workloads to the AWS Cloud. Before joining AWS, Prashant helped various customers use Elasticsearch for their search and analytics use cases.
Evren Sen is a Solutions Architect at AWS, focusing on strategic financial services customers. He helps his customers create Cloud Center of Excellence and design, and deploy solutions on the AWS Cloud. Outside of AWS, Evren enjoys spending time with family and friends, traveling, and cycling.