Skip to content

Commit c230532

Browse files
authored
Included Authenticators (#988)
Signed-off-by: vamsi-amazon <[email protected]>
1 parent 40d8d9f commit c230532

File tree

31 files changed

+708
-190
lines changed

31 files changed

+708
-190
lines changed

core/src/main/java/org/opensearch/sql/catalog/model/AbstractAuthenticationData.java

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

core/src/main/java/org/opensearch/sql/catalog/model/AuthenticationType.java

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

core/src/main/java/org/opensearch/sql/catalog/model/BasicAuthenticationData.java

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

core/src/main/java/org/opensearch/sql/catalog/model/CatalogMetadata.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.fasterxml.jackson.annotation.JsonFormat;
99
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1010
import com.fasterxml.jackson.annotation.JsonProperty;
11+
import java.util.Map;
1112
import lombok.Getter;
1213
import lombok.Setter;
1314

@@ -19,13 +20,11 @@ public class CatalogMetadata {
1920
@JsonProperty(required = true)
2021
private String name;
2122

22-
@JsonProperty(required = true)
23-
private String uri;
24-
2523
@JsonProperty(required = true)
2624
@JsonFormat(with = JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
2725
private ConnectorType connector;
2826

29-
private AbstractAuthenticationData authentication;
27+
@JsonProperty(required = true)
28+
private Map<String, String> properties;
3029

3130
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
*
3+
* * Copyright OpenSearch Contributors
4+
* * SPDX-License-Identifier: Apache-2.0
5+
*
6+
*/
7+
8+
package org.opensearch.sql.catalog.model.auth;
9+
10+
import java.util.Collections;
11+
import java.util.HashMap;
12+
import java.util.Map;
13+
import java.util.concurrent.ConcurrentHashMap;
14+
15+
public enum AuthenticationType {
16+
17+
BASICAUTH("basicauth"), AWSSIGV4AUTH("awssigv4");
18+
19+
private String name;
20+
21+
private static final Map<String, AuthenticationType> ENUM_MAP;
22+
23+
AuthenticationType(String name) {
24+
this.name = name;
25+
}
26+
27+
public String getName() {
28+
return this.name;
29+
}
30+
31+
static {
32+
Map<String, AuthenticationType> map = new HashMap<>();
33+
for (AuthenticationType instance : AuthenticationType.values()) {
34+
map.put(instance.getName().toLowerCase(), instance);
35+
}
36+
ENUM_MAP = Collections.unmodifiableMap(map);
37+
}
38+
39+
public static AuthenticationType get(String name) {
40+
return ENUM_MAP.get(name.toLowerCase());
41+
}
42+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
*
3+
* * Copyright OpenSearch Contributors
4+
* * SPDX-License-Identifier: Apache-2.0
5+
*
6+
*/
7+
8+
package org.opensearch.sql.storage;
9+
10+
import java.util.Map;
11+
import org.opensearch.sql.catalog.model.ConnectorType;
12+
13+
public interface StorageEngineFactory {
14+
15+
ConnectorType getConnectorType();
16+
17+
StorageEngine getStorageEngine(String catalogName, Map<String, String> requiredConfig);
18+
19+
}

docs/user/ppl/admin/catalog.rst

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,22 @@ Definitions of catalog and connector
2626
Example Prometheus Catalog Definition ::
2727

2828
[{
29-
"name" : "prometheus",
29+
"name" : "my_prometheus",
3030
"connector": "prometheus",
31-
"uri" : "http://localhost:9090",
32-
"authentication" : {
33-
"type" : "basicauth",
34-
"username" : "admin",
35-
"password" : "admin"
31+
"properties" : {
32+
"prometheus.uri" : "http://localhost:8080",
33+
"prometheus.auth.type" : "basicauth",
34+
"prometheus.auth.username" : "admin",
35+
"prometheus.auth.password" : "admin"
3636
}
3737
}]
3838
Catalog configuration Restrictions.
3939

40-
* ``name``, ``uri``, ``connector`` are required fields in the catalog configuration.
41-
* All the catalog names should be unique.
42-
* Catalog names should match with the regex of an identifier[``[@*A-Za-z]+?[*a-zA-Z_\-0-9]*``].
43-
* ``prometheus`` is the only connector allowed.
40+
* ``name``, ``connector``, ``properties`` are required fields in the catalog configuration.
41+
* All the catalog names should be unique and match the following regex[``[@*A-Za-z]+?[*a-zA-Z_\-0-9]*``].
42+
* Allowed Connectors.
43+
* ``prometheus`` [More details: `Prometheus Connector <prometheus_connector.rst>`_]
44+
* All the allowed config parameters in ``properties`` are defined in individual connector pages mentioned above.
4445

4546
Configuring catalog in OpenSearch
4647
====================================
@@ -73,14 +74,10 @@ so we can refer a metric and apply stats over it in the following way.
7374

7475
Example source command with prometheus catalog ::
7576

76-
>> source = prometheus.prometheus_http_requests_total | stats avg(@value) by job;
77+
>> source = my_prometheus.prometheus_http_requests_total | stats avg(@value) by job;
7778

7879

7980
Limitations of catalog
8081
====================================
81-
* Catalog settings are global and all PPL users are allowed to fetch data from all the defined catalogs.
82-
* In each catalog, PPL users can access all the data available with the credentials provided in the catalog definition.
83-
* With the current release, Basic and AWSSigV4 are the only authentication mechanisms supported with the underlying data sources.
84-
85-
86-
82+
Catalog settings are global and users with PPL access are allowed to fetch data from all the defined catalogs.
83+
PPL access can be controlled using roles.(More details: `Security Settings <security.rst>`_)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
.. highlight:: sh
2+
3+
====================
4+
Prometheus Connector
5+
====================
6+
7+
.. rubric:: Table of contents
8+
9+
.. contents::
10+
:local:
11+
:depth: 1
12+
13+
14+
Introduction
15+
============
16+
17+
This page covers prometheus connector properties for catalog configuration
18+
and the nuances associated with prometheus connector.
19+
20+
21+
Prometheus Connector Properties in Catalog Configuration
22+
========================================================
23+
Prometheus Connector Properties.
24+
25+
* ``prometheus.uri`` [Required].
26+
* This parameters provides the URI information to connect to a prometheus instance.
27+
* ``prometheus.auth.type`` [Optional]
28+
* This parameters provides the authentication type information.
29+
* Prometheus connector currently supports ``basicauth`` and ``awssigv4`` authentication mechanisms.
30+
* If prometheus.auth.type is basicauth, following are required parameters.
31+
* ``prometheus.auth.username`` and ``prometheus.auth.password``.
32+
* If prometheus.auth.type is awssigv4, following are required parameters.
33+
* ``prometheus.auth.region``, ``prometheus.auth.access_key`` and ``prometheus.auth.secret_key``
34+
35+
Example prometheus catalog configuration with different authentications
36+
=======================================================================
37+
38+
No Auth ::
39+
40+
[{
41+
"name" : "my_prometheus",
42+
"connector": "prometheus",
43+
"properties" : {
44+
"prometheus.uri" : "http://localhost:9090"
45+
}
46+
}]
47+
48+
Basic Auth ::
49+
50+
[{
51+
"name" : "my_prometheus",
52+
"connector": "prometheus",
53+
"properties" : {
54+
"prometheus.uri" : "http://localhost:9090",
55+
"prometheus.auth.type" : "basicauth",
56+
"prometheus.auth.username" : "admin",
57+
"prometheus.auth.password" : "admin"
58+
}
59+
}]
60+
61+
AWSSigV4 Auth::
62+
63+
[{
64+
"name" : "my_prometheus",
65+
"connector": "prometheus",
66+
"properties" : {
67+
"prometheus.uri" : "http://localhost:8080",
68+
"prometheus.auth.type" : "awssigv4",
69+
"prometheus.auth.region" : "us-east-1",
70+
"prometheus.auth.access_key" : "{{accessKey}}"
71+
"prometheus.auth.secret_key" : "{{secretKey}}"
72+
}
73+
}]
74+

docs/user/ppl/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ The query start with search command and then flowing a set of command delimited
3636

3737
- `Catalog Settings <admin/catalog.rst>`_
3838

39+
- `Prometheus Connector <admin/prometheus_connector.rst>`_
40+
3941
* **Commands**
4042

4143
- `Syntax <cmd/syntax.rst>`_

doctest/catalog/catalog.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
{
33
"name" : "my_prometheus",
44
"connector": "prometheus",
5-
"uri" : "http://localhost:9090"
5+
"properties" : {
6+
"prometheus.uri" : "http://localhost:9090"
7+
}
68
}
79
]

integ-test/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ apply plugin: 'java'
3838
apply plugin: 'io.freefair.lombok'
3939
apply plugin: 'com.wiredforcode.spawn'
4040

41+
repositories {
42+
mavenCentral()
43+
maven { url 'https://jitpack.io' }
44+
}
4145

4246
ext {
4347
projectSubstitutions = [:]
@@ -63,6 +67,7 @@ configurations.all {
6367
resolutionStrategy.force "com.fasterxml.jackson.core:jackson-databind:${jackson_databind_version}"
6468
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib:1.6.0"
6569
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib-common:1.6.0"
70+
resolutionStrategy.force "com.squareup.okhttp3:okhttp:4.9.3"
6671
}
6772

6873
dependencies {

integ-test/src/test/resources/catalog/catalog.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
{
33
"name" : "my_prometheus",
44
"connector": "prometheus",
5-
"uri" : "http://localhost:9090"
5+
"properties" : {
6+
"prometheus.uri" : "http://localhost:9090"
7+
}
68
}
79
]

plugin/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ ext {
3939

4040
repositories {
4141
mavenCentral()
42+
maven { url 'https://jitpack.io' }
4243
}
4344

4445
opensearchplugin {
@@ -91,6 +92,7 @@ configurations.all {
9192
resolutionStrategy.force "com.fasterxml.jackson.core:jackson-databind:${jackson_databind_version}"
9293
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib:1.6.0"
9394
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib-common:1.6.0"
95+
resolutionStrategy.force "com.squareup.okhttp3:okhttp:4.9.3"
9496
}
9597
compileJava {
9698
options.compilerArgs.addAll(["-processor", 'lombok.launch.AnnotationProcessorHider$AnnotationProcessor'])
@@ -106,6 +108,7 @@ dependencies {
106108
api "com.fasterxml.jackson.core:jackson-databind:${jackson_databind_version}"
107109
api "com.fasterxml.jackson.core:jackson-annotations:${jackson_version}"
108110

111+
109112
api project(":ppl")
110113
api project(':legacy')
111114
api project(':opensearch')

0 commit comments

Comments
 (0)