Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions plugins/OpenSearch/v1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Overview

Query OpenSearch databases using DSL. This plugin is primarily a wrapper around the `_search` API endpoint that allows for a range of queries.
Comment thread
clarkd marked this conversation as resolved.

See the [OpenSearch API docs](https://docs.opensearch.org/latest/api-reference/search-apis/search/) for more information.

Comment thread
clarkd marked this conversation as resolved.
28 changes: 28 additions & 0 deletions plugins/OpenSearch/v1/dataStreams/indices.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "indices",
"displayName": "Indices",
"baseDataSourceName": "httpRequestUnscoped",
"config": {
"httpMethod": "get",
"pagingConfig_mode": "none",
"pagingConfig_offset_base": 1,
"expandInnerObjects": true,
"endpointPath": "_cat/indices",
Comment thread
richbenwell marked this conversation as resolved.
"pathToData": "",
"getArgs": [],
"headers": []
Comment thread
richbenwell marked this conversation as resolved.
},
"timeframes": false,
"matches": "none",
"visibility": {
"type": "hidden"
},
"metadata": [
{
"name": "index",
"shape": "string",
"displayName": "Index",
"role": "value"
}
]
}
32 changes: 32 additions & 0 deletions plugins/OpenSearch/v1/dataStreams/scripts/search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
if (data.aggregations && data.aggregations.length > 0) {
Comment thread
richbenwell marked this conversation as resolved.
Outdated

const agg = data.aggregations[Object.keys(data.aggregations).at(-1)]; // last aggregation to support pipelining

if(agg.buckets) {

result = agg.buckets;

} else if (agg.values) {

result = [agg.values];

} else if (agg.value) {

result = [{
value: agg.value
}];

} else {

result = [agg];

}

} else {

result = data.hits.hits.map(hit => hit._source);

Comment thread
clarkd marked this conversation as resolved.
}



50 changes: 50 additions & 0 deletions plugins/OpenSearch/v1/dataStreams/search.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "search",
"displayName": "Search",
Comment thread
clarkd marked this conversation as resolved.
"baseDataSourceName": "httpRequestUnscoped",
Comment thread
clarkd marked this conversation as resolved.
"matches": "none",
"manualConfigApply": true,
"config": {
"httpMethod": "post",
"pagingConfig_mode": "none",
"pagingConfig_offset_base": 1,
"expandInnerObjects": true,
"endpointPath": "{{index}}/_search",
"postRequestScript": "search.js",
"getArgs": [],
"headers": [],
"postBody": "{{query}}"
Comment thread
richbenwell marked this conversation as resolved.
},
"ui": [
{
"name": "index",
"type": "autocomplete",
"label": "Index",
"validation": {
"required": true
},
"placeholder": "Select index",
"isMulti": false,
"allowCustomValues": true,
"data": {
"source": "dataStream",
"dataStreamName": "indices"
}
},
{
"name": "query",
"type": "json",
"defaultValue": {
"size": 100
},
"label": "Query body",
"help": "The Query DSL JSON. See [OpenSearch API docs](https://docs.opensearch.org/latest/api-reference/search-apis/search/#request-body).",
Comment thread
clarkd marked this conversation as resolved.
"validation": {
"required": true
}
}
],
"supportsNoneTimeframe": true,
"requiresParameterTimeframe": true,
"defaultTimeframe": "none"
}
21 changes: 21 additions & 0 deletions plugins/OpenSearch/v1/docs/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Configuration

## Instance URL
Comment thread
clarkd marked this conversation as resolved.

The base URL of your OpenSearch database.

For example:
`https://<your-opensearch-host>:9200`

Do *not* include the `/api` path.

## Authentication
Comment thread
richbenwell marked this conversation as resolved.

The data source supports basic (username and password) or anonymous authentication.

If using basic authentication, ensure the user only has read permissions.

If using anonymous, ensure the endpoint is secured in some other form.

If you need to whitelist the IP addresses for SquaredUp these can be found on the [Data Security](https://docs.squaredup.com/reference/security/data-security) KB article.

6 changes: 6 additions & 0 deletions plugins/OpenSearch/v1/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions plugins/OpenSearch/v1/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "open-search",
"displayName": "OpenSearch",
"version": "1.0.3",
Comment thread
clarkd marked this conversation as resolved.
"author": {
"name": "SquaredUp Labs",
"type": "labs"
},
Comment thread
clarkd marked this conversation as resolved.
Comment thread
clarkd marked this conversation as resolved.
"description": "Query OpenSearch databases using DSL.",
Comment thread
clarkd marked this conversation as resolved.
"category": "Database",
"type": "cloud",
"restrictedToPlatforms": [],
"importNotSupported": true,
"schemaVersion": "2.0",
"base": {
Comment thread
richbenwell marked this conversation as resolved.
"plugin": "WebAPI",
"majorVersion": "1",
"config": {
"authMode": "{{authMode}}",
"basicAuthUsername": "{{basicAuthUsername}}",
"basicAuthPassword": "{{basicAuthPassword}}",
"queryArgs": [],
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"baseUrl": "{{instanceUrl}}",
"ignoreCertificateErrors": "{{ignoreCertificateErrors}}"
}
},
"links": [
{
"category": "documentation",
"url": "https://github.com/squaredup/plugins/blob/main/plugins/OpenSearch/v1/docs/setup.md",
"label": "Help adding this plugin"
Comment thread
clarkd marked this conversation as resolved.
},
{
"category": "source",
"url": "https://github.com/squaredup/plugins/tree/main/plugins/OpenSearch/v1",
"label": "Repository"
}
]
}
58 changes: 58 additions & 0 deletions plugins/OpenSearch/v1/ui.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[
{
"type": "text",
"name": "instanceUrl",
"label": "Instance URL",
Comment thread
clarkd marked this conversation as resolved.
"validation": { "required": true },
"placeholder": "Enter the OpenSearch URL"
Comment thread
clarkd marked this conversation as resolved.
},
{
"name": "authMode",
"type": "radio",
"label": "Authentication",
"help": "**Basic:** Authenticate with username and password. \n**Anonymous access:** No authentication required",
Comment thread
clarkd marked this conversation as resolved.
"defaultValue": "basic",
"validation": {
"required": true
},
"options": [
{
"label": "Basic",
"value": "basic"
},
{
"label": "Anonymous access",
"value": "none"
}

]
},
Comment thread
clarkd marked this conversation as resolved.
{
"type": "fieldGroup",
"visible": {
"authMode": "basic"
},
"fields": [
{
"type": "text",
"name": "basicAuthUsername",
"label": "Username",
"validation": { "required": true },
"placeholder": "Enter a username"
},
{
"type": "password",
"name": "basicAuthPassword",
"label": "Password",
"validation": { "required": true },
"placeholder": "Enter a password"
Comment thread
richbenwell marked this conversation as resolved.
}
]
},
{
"type": "checkbox",
"name": "ignoreCertificateErrors",
"label": "Ignore certificate errors",
"help": "Ignore certificate errors when connecting to an OpenSearch instance with a self-signed certificate"
}
]
Loading