Skip to content

Commit fe09f26

Browse files
vamsimanohargithub-actions[bot]
authored andcommitted
Documentation and other papercuts for datasource api launch (#1530)
Signed-off-by: vamsi-amazon <reddyvam@amazon.com> (cherry picked from commit fd1d7d8)
1 parent f76a10b commit fe09f26

File tree

9 files changed

+75
-139
lines changed

9 files changed

+75
-139
lines changed

datasources/src/main/java/org/opensearch/sql/datasources/settings/DataSourceSettings.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111

1212
public class DataSourceSettings {
1313

14+
// we are keeping this to not break upgrades if the config is already present.
15+
// This will be completely removed in 3.0.
1416
public static final Setting<InputStream> DATASOURCE_CONFIG = SecureSetting.secureFile(
1517
"plugins.query.federation.datasources.config",
16-
null);
18+
null,
19+
Setting.Property.Deprecated);
1720

1821
public static final Setting<String> DATASOURCE_MASTER_SECRET_KEY = Setting.simpleString(
1922
"plugins.query.datasources.encryption.masterkey",

datasources/src/main/resources/datasources-index-mapping.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
# SPDX-License-Identifier: Apache-2.0
55
##
66

7-
# Schema file for the observability index
8-
# Since we only search based on "access", sort on lastUpdatedTimeMs & createdTimeMs,
9-
# other fields are not used in mapping to avoid index on those fields.
7+
# Schema file for the .ql-datasources index
108
# Also "dynamic" is set to "false" so that other fields can be added.
119
dynamic: false
1210
properties:
@@ -15,5 +13,5 @@ properties:
1513
fields:
1614
keyword:
1715
type: keyword
18-
connectorType:
16+
connector:
1917
type: keyword

datasources/src/main/resources/datasources-index-settings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# SPDX-License-Identifier: Apache-2.0
55
##
66

7-
# Settings file for the observability index
7+
# Settings file for the .ql-datasources index
88
index:
99
number_of_shards: "1"
1010
auto_expand_replicas: "0-2"

docs/user/ppl/admin/datasources.rst

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ The concept of ``datasource`` is introduced to support the federation of SQL/PPL
1717
This helps PPL users to leverage data from multiple data stores and derive correlation and insights.
1818
Datasource definition provides the information to connect to a data store and also gives a name to them to refer in PPL commands.
1919

20+
Refer below sections for quick setup.
21+
22+
* `Datasource configuration APIs`_
23+
* `Master Key config for encrypting credential information`_
24+
2025

2126
Definitions of datasource and connector
2227
====================================
@@ -47,7 +52,7 @@ Datasource configuration Restrictions.
4752
* ``prometheus`` [More details: `Prometheus Connector <prometheus_connector.rst>`_]
4853
* All the allowed config parameters in ``properties`` are defined in individual connector pages mentioned above.
4954

50-
Datasource configuration Management.
55+
Datasource configuration APIs
5156
======================================
5257
Datasource configuration can be managed using below REST APIs. All the examples below are for OpenSearch domains enabled with secure domain.
5358
we can remove authorization and other details in case of security disabled domains.
@@ -113,6 +118,24 @@ Each of the datasource configuration management apis are controlled by following
113118

114119
Only users mapped with roles having above actions are authorized to execute datasource management apis.
115120

121+
Master Key config for encrypting credential information
122+
========================================================
123+
* When users provide credentials for a data source, the system encrypts and securely stores them in the metadata index. System uses "AES/GCM/NoPadding" symmetric encryption algorithm.
124+
* Users can set up a master key to use with this encryption method by configuring the plugins.query.datasources.encryption.masterkey setting in the opensearch.yml file.
125+
* The master key must be 16, 24, or 32 characters long.
126+
* It's highly recommended that users configure a master key for better security.
127+
* If users don't provide a master key, the system will default to "0000000000000000".
128+
* Sample python script to generate a 24 character master key ::
129+
130+
import random
131+
import string
132+
133+
# Generate a 24-character random master key
134+
master_key = ''.join(random.choices(string.ascii_letters + string.digits, k=24))
135+
136+
# Print the master key
137+
print("Generated master key:", master_key)
138+
116139
Using a datasource in PPL command
117140
====================================
118141
Datasource is referred in source command as show in the code block below.
@@ -127,7 +150,7 @@ Example source command with prometheus datasource ::
127150

128151

129152
Authorization of PPL commands on datasources
130-
==============================================
153+
============================================
131154
In case of secure opensearch domains, only admins and users with roles mentioned in datasource configuration are allowed to make queries.
132155
For example: with below datasource configuration, only admins and users with prometheus_access role can run queries on my_prometheus datasource. ::
133156

@@ -144,7 +167,7 @@ For example: with below datasource configuration, only admins and users with pro
144167
}
145168

146169

147-
Limitations of datasource
148-
====================================
149-
Datasource settings are global and users with PPL access are allowed to fetch data from all the defined datasources.
150-
PPL access can be controlled using roles.(More details: `Security Settings <security.rst>`_)
170+
Moving from keystore datasource configuration
171+
=============================================
172+
* In versions prior to 2.7, the plugins.query.federation.datasources.config key store setting was used to configure datasources, but it has been deprecated and will be removed in version 3.0.
173+
* To port previously configured datasources from the keystore, users can use the `create datasource` REST API mentioned in the above section.

doctest/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ String mlCommonsPlugin = 'opensearch-ml'
121121

122122
testClusters {
123123
docTestCluster {
124-
keystore 'plugins.query.federation.datasources.config', new File("$projectDir/datasource", 'datasources.json')
125124
// Disable loading of `ML-commons` plugin, because it might be unavailable (not released yet).
126125
/*
127126
plugin(provider(new Callable<RegularFile>(){

integ-test/src/test/java/org/opensearch/sql/ppl/InformationSchemaCommandIT.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.json.JSONObject;
1717
import org.junit.After;
1818
import org.junit.AfterClass;
19+
import org.junit.BeforeClass;
1920
import org.junit.jupiter.api.AfterAll;
2021
import org.junit.jupiter.api.BeforeAll;
2122
import org.junit.jupiter.api.Test;
@@ -28,6 +29,18 @@ protected void init() throws Exception {
2829
loadIndex(Index.DATASOURCES);
2930
}
3031

32+
/**
33+
* Integ tests are dependent on self generated metrics in prometheus instance.
34+
* When running individual integ tests there
35+
* is no time for generation of metrics in the test prometheus instance.
36+
* This method gives prometheus time to generate metrics on itself.
37+
* @throws InterruptedException
38+
*/
39+
@BeforeClass
40+
protected static void metricGenerationWait() throws InterruptedException {
41+
Thread.sleep(10000);
42+
}
43+
3144
@Test
3245
public void testSearchTablesFromPrometheusCatalog() throws IOException {
3346
JSONObject result =

integ-test/src/test/java/org/opensearch/sql/ppl/PrometheusDataSourceCommandsIT.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.apache.commons.lang3.StringUtils;
1919
import org.json.JSONArray;
2020
import org.json.JSONObject;
21+
import org.junit.BeforeClass;
2122
import org.junit.jupiter.api.Assertions;
2223
import org.junit.jupiter.api.Test;
2324

@@ -29,6 +30,18 @@ protected void init() throws Exception {
2930
loadIndex(Index.DATASOURCES);
3031
}
3132

33+
/**
34+
* Integ tests are dependent on self generated metrics in prometheus instance.
35+
* When running individual integ tests there
36+
* is no time for generation of metrics in the test prometheus instance.
37+
* This method gives prometheus time to generate metrics on itself.
38+
* @throws InterruptedException
39+
*/
40+
@BeforeClass
41+
protected static void metricGenerationWait() throws InterruptedException {
42+
Thread.sleep(10000);
43+
}
44+
3245
@Test
3346
@SneakyThrows
3447
public void testSourceMetricCommand() {

integ-test/src/test/java/org/opensearch/sql/ppl/ShowDataSourcesCommandIT.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import java.io.IOException;
1616
import org.json.JSONObject;
17+
import org.junit.BeforeClass;
1718
import org.junit.jupiter.api.Test;
1819

1920
public class ShowDataSourcesCommandIT extends PPLIntegTestCase {
@@ -22,6 +23,18 @@ protected void init() throws Exception {
2223
loadIndex(Index.DATASOURCES);
2324
}
2425

26+
/**
27+
* Integ tests are dependent on self generated metrics in prometheus instance.
28+
* When running individual integ tests there
29+
* is no time for generation of metrics in the test prometheus instance.
30+
* This method gives prometheus time to generate metrics on itself.
31+
* @throws InterruptedException
32+
*/
33+
@BeforeClass
34+
protected static void metricGenerationWait() throws InterruptedException {
35+
Thread.sleep(10000);
36+
}
37+
2538
@Test
2639
public void testShowDataSourcesCommands() throws IOException {
2740
JSONObject result = executeQuery("show datasources");

scripts/integtest.sh

Lines changed: 0 additions & 126 deletions
This file was deleted.

0 commit comments

Comments
 (0)