Skip to content

Commit

Permalink
AWS Authentication (#504)
Browse files Browse the repository at this point in the history
* interface{} to any :)

* update deps

* updated UQL

* added AWS authentication

* fix lint errors
  • Loading branch information
yesoreyeram authored Jan 11, 2023
1 parent d684a8a commit 4941b98
Show file tree
Hide file tree
Showing 47 changed files with 1,269 additions and 968 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Setup Go environment
uses: actions/setup-go@v2
with:
go-version: '1.19.3'
go-version: '1.19.5'
- name: Get go cache directory path
id: go-cache-paths
run: echo "::set-output name=go-mod::$(go env GOMODCACHE)"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup Go environment
uses: actions/setup-go@v2
with:
go-version: '1.19.3'
go-version: '1.19.5'
- name: Get go cache directory path
id: go-cache-paths
run: echo "::set-output name=go-mod::$(go env GOMODCACHE)"
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,5 @@ cypress/report.json
cypress/screenshots/
cypress/videos/
.data/

./temp_test.go
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Change history of the project. All the feature updates, bug fixes, breaking changes will be documented here.

## [ 1.3.0 ]

- **Auth** Added support for **AWS authentication** using AWS Access and AWS Secret key
- **UQL** Support for new methods `atob`, `btoa` and `substring`
- **Chore** Backend binaries are now compiled with Go 1.19.5

## [ 1.2.0 ]

- **XML** Support for backend parser (alerts, recorded queries, public dashboards etc)
Expand Down
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ If you want to contribute to the plugin, you can contribute in one of the follow
You need following tools in your local machine for development

- NodeJS v16.0+
- Go 1.18
- Go 1.19
- Mage

Once you clone the repo locally in the grafana's plugin folder. Do the following steps

- `yarn` - This will install the frontend dependencies. Do this once
- `mage -v` - This will help to build the backend part of the plugin. Do this once if you are contributing only the frontend. There is no significant code is in the backend. So no much changes expected
- `yarn watch` - For continuously watching the front-end changes and build
- `mage -v` - This will help to build the backend part of the plugin. Do this once if you are contributing only the frontend. There is no significant code is in the backend. So no much changes expected
- `docker-compose up` - To run the plugin with grafana locally. ( use infinity:infinity as the credentials )
- `yarn test` - To make sure all the existing tests passed

## Setting up the plugin docs site locally

- `cd website & yarn dev` - To build and see the changes of docs website
- `cd website & yarn build` - To build the docs website
6 changes: 6 additions & 0 deletions cspell.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"try/provisioning/**",
"pkg/testdata/**",
"pkg/**/*_test.go",
"/temp_test.go",
"website/node_modules/**",
"website/public/**",
"try/dashboards/**",
Expand All @@ -17,7 +18,10 @@
"words": [
"ANSIC",
"basgys",
"Bauch",
"builtins",
"Chelsey",
"clientcredentials",
"Collapsable",
"compatibilitycheck",
"countif",
Expand Down Expand Up @@ -57,6 +61,7 @@
"kennethreitz",
"Knetic",
"kusto",
"Lebsack",
"magefile",
"mainbg",
"maxif",
Expand All @@ -83,6 +88,7 @@
"promhttp",
"scroller",
"seriesgen",
"sigv",
"sourashtra",
"sriram",
"sriramajeyam",
Expand Down
2 changes: 1 addition & 1 deletion cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"include": ["**/*.ts"],
"compilerOptions": {
"baseUrl": "../node_modules",
"types": ["cypress", "@grafana/e2e/cypress/support", "node"]
"types": ["cypress", "node"]
}
}
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ version: '3.7'
services:
grafana:
container_name: yesoreyeram-infinity-datasource
image: grafana/grafana-enterprise:8.4.7
# image: grafana/grafana-enterprise:9.2.0
image: grafana/grafana-enterprise:9.3.1
# image: grafana/grafana-enterprise:8.4.7
# image: grafana/grafana-enterprise:main
ports:
- '3000:3000'
Expand All @@ -17,4 +17,4 @@ services:
- GF_SECURITY_ADMIN_USER=infinity
- GF_SECURITY_ADMIN_PASSWORD=infinity
- GF_ENTERPRISE_LICENSE_TEXT=$GF_ENTERPRISE_LICENSE_TEXT
- GF_FEATURE_TOGGLES_ENABLE=publicDashboards
- GF_FEATURE_TOGGLES_ENABLE=publicDashboards topnav
8 changes: 8 additions & 0 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,11 @@ OAuth2 JWT require the following parameters
| Token URL | TokenURL is the endpoint required to complete the 2-legged JWT flow |
| Subject | Optional. Subject is the optional user to impersonate |
| Scopes | Scopes optionally specifies a list of requested permission scopes. Provide scopes as a comma separated values |

## Azure Authentication

If you want to authenticate your API endpoints via microsoft azure authentication, refer steps given [here](/wiki/azure-authentication).

## AWS Authentication

If you want to authenticate your API endpoints via amazon aws authentication, refer steps given [here](/wiki/aws-authentication).
57 changes: 57 additions & 0 deletions docs/aws-authentication.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
slug: '/wiki/aws-authentication'
title: 'AWS Authentication'
previous_page_title: 'Authentication'
previous_page_slug: '/wiki/authentication'
next_page_title: 'Configuration'
next_page_slug: '/wiki/configuration'
---

## AWS authentication

Support for connecting to AWS API is available from version 1.3.0

## Steps to connect to AWS APIs

1. Create a new service account in [AWS console](https://us-east-1.console.aws.amazon.com/iam/home#/users$new?step=details). ( AWS Console -> IAM -> Access Management -> Users -> Add users)
1. Select **Access key - Programmatic access** as AWS Credentials type
2. Set required permissions ( preferably CloudWatch ReadOnly Permission )
3. Copy the access key and secret key
2. Install the infinity plugin in Grafana and add data source for the same
3. Expand Authentication section and select "AWS"
4. Select region. Example `us-east-1`
5. Select service. Example `monitoring`. You can find the appropriate service name [here](https://docs.aws.amazon.com/general/latest/gr/aws-service-information.html).
6. Enter the access key and secret key you copied in step 1
7. Enter `https://monitoring.us-east-1.amazonaws.com` as allowed URL. (replace the service name and region as necessary )
8. Click "Save and Test"
9. Click the Explore button
10. Enter the URL `https://monitoring.us-east-1.amazonaws.com?Action=ListMetrics`
11. Select "JSON" as Query type
12. Optionally, Select "Backend" / "UQL" as parser.
13. Enter the Root Selector `ListMetricsResponse.ListMetricsResult.Metrics`
14. Click Run Query and you will see the results

## Config Editor

![image](https://user-images.githubusercontent.com/153843/210791648-7d05d435-2a26-469c-9bfd-e4db98018999.png#center)

## Query with Backend parser

![image](https://user-images.githubusercontent.com/153843/210788954-e8bf3fab-e1c7-426d-8e87-610315c6afee.png#center)

## Query with UQL parser

![image](https://user-images.githubusercontent.com/153843/210791302-178391c9-93f9-4449-8f5a-8e14a3db1eff.png#center)

sample uql query is given below

```sql
parse-json
| scope "ListMetricsResponse.ListMetricsResult.Metrics"
| mv-expand "dimension"="Dimensions"
| project "Namespace", "MeasureName", "Dimension Name"="dimension.Name", "Dimension Value"="dimension.Value"
```

## Query with Default/Frontend parser

![image](https://user-images.githubusercontent.com/153843/210790702-af822bdc-e974-4410-83b2-8e7776f03516.png#center)
2 changes: 1 addition & 1 deletion docs/backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ slug: '/wiki/backend'
title: 'Backend Parser'
previous_page_title: 'UQL'
previous_page_slug: '/wiki/uql'
next_page_title: 'Groq'
next_page_title: 'GROQ'
next_page_slug: '/wiki/groq'
---

Expand Down
6 changes: 3 additions & 3 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ grafana-cli --pluginUrl https://github.com/yesoreyeram/grafana-infinity-datasour

### Install using helm chart

If you use helm chart to provision grafana, use the following config to install the plugin
If you use [grafana helm chart](https://github.com/grafana/helm-charts/blob/grafana-6.32.12/charts/grafana/values.yaml#L482) to provision grafana, use the following config to install the plugin

```yml
plugins:
Expand All @@ -65,11 +65,11 @@ plugins:
With docker, you can install the plugin using the following command. This will download the latest published version of the plugin from grafana plugins directory.
```shell
docker run -p 3000:3000 -e "GF_INSTALL_PLUGINS=yesoreyeram-infinity-datasource" grafana/grafana-enterprise:8.4.7
docker run -p 3000:3000 -e "GF_INSTALL_PLUGINS=yesoreyeram-infinity-datasource" grafana/grafana-enterprise:9.3.1
```

If you need to install a custom version of the plugin with docker, use the following command.

```shell
docker run -p 3000:3000 -e "GF_INSTALL_PLUGINS=https://github.com/yesoreyeram/grafana-infinity-datasource/releases/download/v1.2.0/yesoreyeram-infinity-datasource-1.2.0.zip;yesoreyeram-infinity-datasource" grafana/grafana-enterprise:8.4.7
docker run -p 3000:3000 -e "GF_INSTALL_PLUGINS=https://github.com/yesoreyeram/grafana-infinity-datasource/releases/download/v1.2.0/yesoreyeram-infinity-datasource-1.2.0.zip;yesoreyeram-infinity-datasource" grafana/grafana-enterprise:9.3.1
```
Loading

0 comments on commit 4941b98

Please sign in to comment.