Skip to content

Commit

Permalink
Merge dev into main (#66)
Browse files Browse the repository at this point in the history
Signed-off-by: David Cui <[email protected]>

Co-authored-by: Zhongnan Su <[email protected]>
Co-authored-by: Joshua <[email protected]>
Co-authored-by: Carl Meadows <[email protected]>
Co-authored-by: Kevin Masseix <[email protected]>
Co-authored-by: Uzhinskiy Boris <[email protected]>
  • Loading branch information
6 people committed May 27, 2021
1 parent 4ba7ff4 commit 8f8357b
Show file tree
Hide file tree
Showing 132 changed files with 3,394 additions and 1,558 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dashboards-reports-release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:

env:
PLUGIN_NAME: reportsDashboards
OPENSEARCH_VERSION: 1.0.0-beta1
OPENSEARCH_PLUGIN_VERSION: 1.0.0.0-beta1
OPENSEARCH_VERSION: '1.0'
OPENSEARCH_PLUGIN_VERSION: 1.0.0.0-rc1

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on: [pull_request, push]

env:
PLUGIN_NAME: reportsDashboards
OPENSEARCH_VERSION: 1.0.0-beta1
OPENSEARCH_PLUGIN_VERSION: 1.0.0.0-beta1
OPENSEARCH_VERSION: '1.0'
OPENSEARCH_PLUGIN_VERSION: 1.0.0.0-rc1

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reports-scheduler-release-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Release Reports Scheduler Artifacts
# This workflow is triggered on creating tags to master or an opendistro release branch
# This workflow is triggered on creating tags to master or an opensearch release branch
on:
push:
tags:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/reports-scheduler-test-and-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,32 @@ jobs:
with:
repository: 'opensearch-project/OpenSearch'
path: OpenSearch
ref: '1.0.0-beta1'
ref: '1.0'
- name: Build OpenSearch
working-directory: ./OpenSearch
run: ./gradlew publishToMavenLocal -Dbuild.version_qualifier=beta1 -Dbuild.snapshot=false
run: ./gradlew publishToMavenLocal -Dbuild.version_qualifier=rc1 -Dbuild.snapshot=false

# dependencies: common-utils
- name: Checkout common-utils
uses: actions/checkout@v2
with:
repository: 'opensearch-project/common-utils'
ref: '1.0.0-beta1'
ref: 'main'
path: common-utils
- name: Build common-utils
working-directory: ./common-utils
run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0-beta1
run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0-rc1

# dependencies: job-scheduler
- name: Checkout job-scheduler
uses: actions/checkout@v2
with:
repository: 'opensearch-project/job-scheduler'
ref: '1.0.0-beta1'
ref: 'main'
path: job-scheduler
- name: Build job-scheduler
working-directory: ./job-scheduler
run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0-beta1 -Dbuild.snapshot=false
run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0-rc1 -Dbuild.snapshot=false

# reports-scheduler
- name: Checkout Reports Scheduler
Expand All @@ -52,7 +52,7 @@ jobs:
- name: Build with Gradle
run: |
cd reports-scheduler
./gradlew build -Dopensearch.version=1.0.0-beta1
./gradlew build -Dopensearch.version=1.0.0-rc1
- name: Create Artifact Path
run: |
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[![OpenSearch Dashboards Reports CI](https://github.com/opensearch-project/dashboards-reports/workflows/Test%20and%20Build%20OpenSearch%20Dashboards%20Reports/badge.svg)](https://github.com/opensearch-project/dashboards-reports/actions?query=workflow%3A%22Test+and+Build+OpenSearch+Dashboards+Reports%22)
[![Reports Scheduler CI](https://github.com/opensearch-project/dashboards-reports/workflows/Test%20and%20Build%20Reports%20Scheduler/badge.svg)](https://github.com/opensearch-project/dashboards-reports/actions?query=workflow%3A%22Test+and+Build+Reports+Scheduler%22)
[![codecov](https://codecov.io/gh/opensearch-project/dashboards-reports/branch/dev/graph/badge.svg?token=FBVYQSZD3B)](https://codecov.io/gh/opensearch-project/dashboards-reports)
[![Documentation](https://img.shields.io/badge/documentation-blue.svg)](https://opendistro.github.io/for-elasticsearch-docs/docs/kibana/reporting/)
[![Documentation](https://img.shields.io/badge/documentation-blue.svg)](https://docs-beta.opensearch.org/docs/opensearch-dashboards/reporting/)
![PRs welcome!](https://img.shields.io/badge/PRs-welcome!-success)

# OpenSearch Dashboards Reports for Open Distro
# OpenSearch Dashboards Reports

OpenSearch Dashboards Reports for Open Distro allows ‘Report Owner’ (engineers, including but not limited to developers, DevOps, IT Engineer, and IT admin) export and share reports from OpenSearch Dashboards dashboards, saved search, alerts and visualizations. It helps automate the process of scheduling reports on an on-demand or a periodical basis (on cron schedules as well). Further, it also automates the process of exporting and sharing reports triggered for various alerts. The feature is present in the Dashboard, Discover, and Visualization tabs. Scheduled reports can be sent to (shared with) self or various stakeholders within the organization such as, including but not limited to, executives, managers, engineers (developers, DevOps, IT Engineer) in the form of pdf, hyperlinks, csv, excel via various channels such as email, slack, Amazon Chime. However, in order to export, schedule and share reports, report owners should have the necessary permissions as defined under Roles and Privileges.
OpenSearch Dashboards Reports allows ‘Report Owner’ (engineers, including but not limited to developers, DevOps, IT Engineer, and IT admin) export and share reports from OpenSearch Dashboards dashboards, saved search, alerts and visualizations. It helps automate the process of scheduling reports on an on-demand or a periodical basis (on cron schedules as well). Further, it also automates the process of exporting and sharing reports triggered for various alerts. The feature is present in the Dashboard, Discover, and Visualization tabs. Scheduled reports can be sent to (shared with) self or various stakeholders within the organization such as, including but not limited to, executives, managers, engineers (developers, DevOps, IT Engineer) in the form of pdf, hyperlinks, csv, excel via various channels such as email, slack, Amazon Chime. However, in order to export, schedule and share reports, report owners should have the necessary permissions as defined under Roles and Privileges.

# Request for Comments ( RFC )

Expand All @@ -29,7 +29,7 @@ There could be two reasons for this problem

2. Missing additional dependencies. Please refer to [additional dependencies section](./dashboards-reports/rendering-engine/headless-chrome/README.md#additional-libaries) to install required dependencies according to your operating system.

## Contributing to OpenSearch Dashboards reports for Open Distro
## Contributing to OpenSearch Dashboards reports

We welcome you to get involved in development, documentation, testing the OpenSearch Dashboards reports plugin. See our [CONTRIBUTING.md](./CONTRIBUTING.md) and join in.

Expand Down
4 changes: 2 additions & 2 deletions dashboards-reports/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OpenSearch Dashboards Reports

OpenSearch Dashboards Reports for Open Distro allows ‘Report Owner’ (engineers, including but not limited to developers, DevOps, IT Engineer, and IT admin) export and share reports from OpenSearch Dashboards dashboards, saved search, alerts and visualizations. It helps automate the process of scheduling reports on an on-demand or a periodical basis (on cron schedules as well). Further, it also automates the process of exporting and sharing reports triggered for various alerts. The feature is present in the Dashboard, Discover, and Visualization tabs. Scheduled reports can be sent to (shared with) self or various stakeholders within the organization such as, including but not limited to, executives, managers, engineers (developers, DevOps, IT Engineer) in the form of pdf, hyperlinks, csv, excel via various channels such as email, slack, Amazon Chime. However, in order to export, schedule and share reports, report owners should have the necessary permissions as defined under Roles and Privileges.
OpenSearch Dashboards Reports allows ‘Report Owner’ (engineers, including but not limited to developers, DevOps, IT Engineer, and IT admin) export and share reports from OpenSearch Dashboards dashboards, saved search, alerts and visualizations. It helps automate the process of scheduling reports on an on-demand or a periodical basis (on cron schedules as well). Further, it also automates the process of exporting and sharing reports triggered for various alerts. The feature is present in the Dashboard, Discover, and Visualization tabs. Scheduled reports can be sent to (shared with) self or various stakeholders within the organization such as, including but not limited to, executives, managers, engineers (developers, DevOps, IT Engineer) in the form of pdf, hyperlinks, csv, excel via various channels such as email, slack, Amazon Chime. However, in order to export, schedule and share reports, report owners should have the necessary permissions as defined under Roles and Privileges.

# Request for Comments ( RFC )

Expand Down Expand Up @@ -49,7 +49,7 @@ Example output: `./build/reports-dashboards-0.0.1.zip`

Runs the plugin tests.

## Contributing to OpenSearch Dashboards reports for Open Distro
## Contributing to OpenSearch Dashboards reports

We welcome you to get involved in development, documentation, testing the OpenSearch Dashboards reports plugin. See our [CONTRIBUTING.md](./CONTRIBUTING.md) and join in.

Expand Down
4 changes: 2 additions & 2 deletions dashboards-reports/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export const PLUGIN_NAME = 'reports-dashboards';
export const API_PREFIX = '/api/reporting';

export const NOTIFICATION_API = {
SEND: '/_opendistro/_notifications/send',
SEND: '/_plugins/_notifications/send',
};

const BASE_REPORTS_URI = '/_opendistro/_reports';
const BASE_REPORTS_URI = '/_plugins/_reports';

export const OPENSEARCH_REPORTS_API = {
ON_DEMAND_REPORT: `${BASE_REPORTS_URI}/on_demand`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This plugin will introduce the ability to generate reports, as well as enable th

### 1.2 Introduction

OpenSearch Dashboards Reports for Open Distro allows ‘Report Owner’ (engineers, including but not limited to developers, DevOps, IT Engineer, and IT admin) export and share reports from OpenSearch Dashboards dashboards, saved search, alerts and visualizations. It helps automate the process of scheduling reports on an on-demand or a periodical basis (on cron schedules as well). Further, it also automates the process of exporting and sharing reports triggered for various alerts. The feature is present in the Dashboard, Discover, and Visualization tabs. Scheduled reports can be sent to (shared with) self or various stakeholders within the organization such as, including but not limited to, executives, managers, engineers (developers, DevOps, IT Engineer) in the form of pdf, hyperlinks, csv, excel via various channels such as email, slack, Amazon Chime. However, in order to export, schedule and share reports, report owners should have the necessary permissions as defined under Roles and Privileges.
OpenSearch Dashboards Reports allows ‘Report Owner’ (engineers, including but not limited to developers, DevOps, IT Engineer, and IT admin) export and share reports from OpenSearch Dashboards dashboards, saved search, alerts and visualizations. It helps automate the process of scheduling reports on an on-demand or a periodical basis (on cron schedules as well). Further, it also automates the process of exporting and sharing reports triggered for various alerts. The feature is present in the Dashboard, Discover, and Visualization tabs. Scheduled reports can be sent to (shared with) self or various stakeholders within the organization such as, including but not limited to, executives, managers, engineers (developers, DevOps, IT Engineer) in the form of pdf, hyperlinks, csv, excel via various channels such as email, slack, Amazon Chime. However, in order to export, schedule and share reports, report owners should have the necessary permissions as defined under Roles and Privileges.


## 2. Requirements
Expand Down Expand Up @@ -192,10 +192,10 @@ List of curated headless browsers https://github.com/dhamaniasad/HeadlessBrowser
|Java |[Selenium](https://www.selenium.dev/) |No support for PDF generation |
| |[jBrowserDriver](https://github.com/MachinePublishers/jBrowserDriver) |No support for PDF generation |

**(II)** To generate CSV reports based on SQL queries, we will be leveraging OpenDistro SQL plugin with **`format=csv`**
**(II)** To generate CSV reports based on SQL queries, we will be leveraging OpenSearch SQL plugin with **`format=csv`**

```
POST _opendistro/_sql?format=csv
POST _plugins/_sql?format=csv
{
"query" : "SELECT ... FROM ... WHERE ... ORDER BY ..."
}
Expand Down Expand Up @@ -423,7 +423,7 @@ listReportEvents()

### 4.3 Job Scheduler APIs

https://github.com/opendistro-for-elasticsearch/job-scheduler
https://github.com/opensearch-project/job-scheduler

**(A) createSchedule**

Expand All @@ -439,12 +439,12 @@ Scheduled Report Creation workflow

### 4.4 Alerting Integration

https://opendistro.github.io/for-elasticsearch-docs/docs/alerting/
https://docs-beta.opensearch.org/docs/alerting/

ODFE Alerting can be used as an external trigger. To generate the report the `generateReport()` API can be utilized as `custom_webhook` destination.

```
POST _opendistro/_alerting/destinations
POST _plugins/_alerting/destinations
{
"type": "custom_webhook",
Expand Down Expand Up @@ -486,7 +486,7 @@ TODO

### (II) Security reference

* https://opendistro.github.io/for-elasticsearch-docs/docs/security-configuration/concepts/
* https://opendistro.github.io/for-elasticsearch-docs/docs/security-access-control/
* https://opendistro.github.io/for-elasticsearch-docs/docs/security-access-control/api/
* https://docs-beta.opensearch.org/docs/security/configuration/
* https://docs-beta.opensearch.org/docs/security/access-control/
* https://docs-beta.opensearch.org/docs/security/access-control/api/

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OpenSearch Dashboards Reporting
## Overview
OpenSearch Dashboards Reports for Open Distro allows `report owners` (including but not limited to Developers, DevOps, IT Engineers, and IT admins) to export and share reports from OpenSearch Dashboards dashboards, saved queries, alerts and visualizations. It helps automate the process of scheduling reports via on-demand or periodic basis (including cron schedules). It also automates exporting and sharing reports from triggers, such as alerts. The feature is present in the Dashboard, Discover, and Visualization tabs. Scheduled reports can be sent to (shared with) self or various stakeholders within the organization such as, including but not limited to, executives, managers, engineers (developers, DevOps, IT Engineer) in the form of pdf, hyperlinks, csv, excel via various channels such as email or the OpenSearch Dashboards reporting plugin.
OpenSearch Dashboards Reports allows `report owners` (including but not limited to Developers, DevOps, IT Engineers, and IT admins) to export and share reports from OpenSearch Dashboards dashboards, saved queries, alerts and visualizations. It helps automate the process of scheduling reports via on-demand or periodic basis (including cron schedules). It also automates exporting and sharing reports from triggers, such as alerts. The feature is present in the Dashboard, Discover, and Visualization tabs. Scheduled reports can be sent to (shared with) self or various stakeholders within the organization such as, including but not limited to, executives, managers, engineers (developers, DevOps, IT Engineer) in the form of pdf, hyperlinks, csv, excel via various channels such as email or the OpenSearch Dashboards reporting plugin.

## Key user flows
### From source
Expand Down
6 changes: 3 additions & 3 deletions dashboards-reports/opensearch_dashboards.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"id": "reportsDashboards",
"version": "1.0.0.0-beta1",
"opensearchDashboardsVersion": "1.0.0-beta1",
"requiredPlugins": ["navigation", "data"],
"version": "1.0.0.0-rc1",
"opensearchDashboardsVersion": "1.0.0-rc1",
"requiredPlugins": ["navigation", "data", "opensearchDashboardsUtils"],
"optionalPlugins": ["share"],
"server": true,
"ui": true
Expand Down
9 changes: 5 additions & 4 deletions dashboards-reports/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "reports_dashboards",
"version": "1.0.0.0-beta1",
"version": "1.0.0.0-rc1",
"description": "OpenSearch Dashboards Reports Plugin",
"license": "Apache-2.0",
"main": "index.ts",
"opensearchDashboards": {
"version": "1.0.0-beta1",
"templateVersion": "1.0.0-beta1"
"version": "1.0.0-rc1",
"templateVersion": "1.0.0-rc1"
},
"scripts": {
"osd": "node ../../scripts/osd",
Expand Down Expand Up @@ -73,6 +73,7 @@
"trim": "^1.0.0",
"doc-path": "2.1.2",
"y18n": "^5.0.5",
"lodash": "^4.17.21"
"lodash": "^4.17.21",
"path-parse": "^1.0.7"
}
}
33 changes: 8 additions & 25 deletions dashboards-reports/public/components/context_menu/context_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
displayLoadingModal,
addSuccessOrFailureToast,
contextMenuViewReports,
replaceQueryURL,
} from './context_menu_helpers';
import {
popoverMenu,
Expand All @@ -42,25 +43,7 @@ import {
} from './context_menu_ui';
import { timeRangeMatcher } from '../utils/utils';
import { parse } from 'url';

const replaceQueryURL = () => {
let url = location.pathname + location.hash;
let [, fromDateString, toDateString] = url.match(timeRangeMatcher);
fromDateString = fromDateString.replace(/[']+/g, '');

// convert time range to from date format in case time range is relative
const fromDateFormat = dateMath.parse(fromDateString);
toDateString = toDateString.replace(/[']+/g, '');
const toDateFormat = dateMath.parse(toDateString);

// replace to and from dates with absolute date
url = url.replace(fromDateString, "'" + fromDateFormat.toISOString() + "'");
url = url.replace(
toDateString + '))',
"'" + toDateFormat.toISOString() + "'))"
);
return url;
};
import { unhashUrl } from '../../../../../src/plugins/opensearch_dashboards_utils/public';

const generateInContextReport = async (
timeRanges,
Expand Down Expand Up @@ -126,7 +109,7 @@ const generateInContextReport = async (
{
headers: {
'Content-Type': 'application/json',
'osd-version': '1.0.0-beta1',
'osd-xsrf': 'reporting',
accept: '*/*',
'accept-language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,zh-TW;q=0.6',
pragma: 'no-cache',
Expand Down Expand Up @@ -190,21 +173,21 @@ $(function () {
// generate PDF onclick
$(document).on('click', '#generatePDF', function () {
const timeRanges = getTimeFieldsFromUrl();
const queryUrl = replaceQueryURL();
const queryUrl = replaceQueryURL(location.href);
generateInContextReport(timeRanges, queryUrl, 'pdf');
});

// generate PNG onclick
$(document).on('click', '#generatePNG', function () {
const timeRanges = getTimeFieldsFromUrl();
const queryUrl = replaceQueryURL();
const queryUrl = replaceQueryURL(location.href);
generateInContextReport(timeRanges, queryUrl, 'png');
});

// generate CSV onclick
$(document).on('click', '#generateCSV', function () {
const timeRanges = getTimeFieldsFromUrl();
const queryUrl = replaceQueryURL();
const queryUrl = replaceQueryURL(location.href);
const saved_search_id = getUuidFromUrl()[1];
generateInContextReport(timeRanges, queryUrl, 'csv', { saved_search_id });
});
Expand Down Expand Up @@ -340,7 +323,7 @@ async function getTenantInfoIfExists() {
const res = await fetch(`../api/v1/multitenancy/tenant`, {
headers: {
'Content-Type': 'application/json',
'osd-version': '1.0.0-beta1',
'osd-xsrf': 'reporting',
accept: '*/*',
'accept-language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,zh-TW;q=0.6',
pragma: 'no-cache',
Expand Down Expand Up @@ -376,7 +359,7 @@ async function getTenantInfoIfExists() {
// helper function to add tenant info to url(if tenant is available)
function addTenantToURL(url, userRequestedTenant) {
// build fake url from relative url
const fakeUrl = `http://opendistro.com${url}`;
const fakeUrl = `http://opensearch.com${url}`;
const tenantKey = 'security_tenant';
const tenantKeyAndValue =
tenantKey + '=' + encodeURIComponent(userRequestedTenant);
Expand Down
Loading

0 comments on commit 8f8357b

Please sign in to comment.