diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index af26e20..6d1ae88 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -9,15 +9,15 @@ well. There are many ways you can contribute! :heart: ### Bug Reports and Fixes :bug: -- If you find a bug, please search for it in the [Issues](https://github.com/slackhq/slack-kaldb-app/issues), and if it isn't already tracked, - [create a new issue](https://github.com/slackhq/slack-kaldb-app/issues/new). Fill out the "Bug Report" section of the issue template. Even if an Issue is closed, feel free to comment and add details, it will still +- If you find a bug, please search for it in the [Issues](https://github.com/slackhq/slack-astra-app/issues), and if it isn't already tracked, + [create a new issue](https://github.com/slackhq/slack-astra-app/issues/new). Fill out the "Bug Report" section of the issue template. Even if an Issue is closed, feel free to comment and add details, it will still be reviewed. - Issues that have already been identified as a bug (note: able to reproduce) will be labelled `bug`. - If you'd like to submit a fix for a bug, [send a Pull Request](#creating_a_pull_request) and mention the Issue number. - Include tests that isolate the bug and verifies that it was fixed. ### New Features :bulb: -- If you'd like to add new functionality to this project, describe the problem you want to solve in a [new Issue](https://github.com/slackhq/slack-kaldb-app/issues/new). +- If you'd like to add new functionality to this project, describe the problem you want to solve in a [new Issue](https://github.com/slackhq/slack-astra-app/issues/new). - Issues that have been identified as a feature request will be labelled `enhancement`. - If you'd like to implement the new feature, please wait for feedback from the project maintainers before spending too much time writing the code. In some cases, `enhancement`s may @@ -28,7 +28,7 @@ There are many ways you can contribute! :heart: alternative implementation of something that may have advantages over the way its currently done, or you have any other change, we would be happy to hear about it! - If its a trivial change, go ahead and [send a Pull Request](#creating_a_pull_request) with the changes you have in mind. - - If not, [open an Issue](https://github.com/slackhq/slack-kaldb-app/issues/new) to discuss the idea first. + - If not, [open an Issue](https://github.com/slackhq/slack-astra-app/issues/new) to discuss the idea first. If you're new to our project and looking for some way to make your first contribution, look for Issues labelled `good first contribution`. @@ -37,7 +37,7 @@ Issues labelled `good first contribution`. For your contribution to be accepted: -- [x] You must have signed the [Contributor License Agreement (CLA)](https://cla-assistant.io/slackhq/slack-kaldb-app). +- [x] You must have signed the [Contributor License Agreement (CLA)](https://cla-assistant.io/slackhq/slack-astra-app). - [x] The test suite must be complete and pass. - [x] The changes must be approved by code review. - [x] Commits should be atomic and messages must be descriptive. Related issues should be mentioned by Issue number. @@ -93,7 +93,7 @@ There are more details about processes and workflow in the [Maintainer's Guide]( #### Proxying Depending on your setup, it may be advantageous for you to setup a proxy from your -local machine to a KalDB query node running in a cloud environment. Below is +local machine to a Astra query node running in a cloud environment. Below is an example command to do that (NOTE: this may or may not work depending on your setup): ``` @@ -101,7 +101,7 @@ ssh -N -L $LOCALHOST_PORT:localhost:$REMOTE_PORT $NODE_NAME ``` You would then be able to use `host.docker.internal:$LOCALHOST_PORT` as the -KalDB datasource URL inside your Grafana instance. +Astra datasource URL inside your Grafana instance. ### Backend diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index e6d65f3..be4c7bc 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -11,7 +11,7 @@ Describe your issue here. - [ ] discussion ### Requirements (place an `x` in each of the `[ ]`) -* [ ] I've read and understood the [Contributing guidelines](https://github.com/slackhq/slack-kaldb-app/blob/master/.github/contributing.md) and have done my best effort to follow them. +* [ ] I've read and understood the [Contributing guidelines](https://github.com/slackhq/slack-astra-app/blob/master/.github/contributing.md) and have done my best effort to follow them. * [ ] I've read and agree to the [Code of Conduct](https://slackhq.github.io/code-of-conduct). * [ ] I've searched for any related issues and avoided creating a duplicate issue. @@ -23,7 +23,7 @@ Filling out the following details about bugs will help us solve your issue soone #### Reproducible in: -slack-kaldb-app version: +slack-astra-app version: Go version: diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index a1007e2..fc4e94f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,7 +4,7 @@ Describe the goal of this PR. Mention any related Issue numbers. ### Requirements (place an `x` in each `[ ]`) -* [ ] I've read and understood the [Contributing Guidelines](https://github.com/slackhq/slack-kaldb-app/blob/master/.github/contributing.md) and have done my best effort to follow them. +* [ ] I've read and understood the [Contributing Guidelines](https://github.com/slackhq/slack-astra-app/blob/master/.github/contributing.md) and have done my best effort to follow them. * [ ] I've read and agree to the [Code of Conduct](https://slackhq.github.io/code-of-conduct). > The following point can be removed after setting up CI (such as Travis) with coverage reports (such as Codecov) @@ -13,4 +13,4 @@ Describe the goal of this PR. Mention any related Issue numbers. > The following point can be removed after setting up a CLA reporting tool such as cla-assistant.io -* [ ] I've read, agree to, and signed the [Contributor License Agreement (CLA)](https://cla-assistant.io/slackhq/slack-kaldb-app). +* [ ] I've read, agree to, and signed the [Contributor License Agreement (CLA)](https://cla-assistant.io/slackhq/slack-astra-app). diff --git a/.gitignore b/.gitignore index 56ad4cb..67122e2 100644 --- a/.gitignore +++ b/.gitignore @@ -26,5 +26,5 @@ ci/ e2e-results/ /.idea -/slack-kaldb-app.zip +/slack-astra-app.zip .DS_Store diff --git a/CHANGELOG.md b/CHANGELOG.md index 50df2c3..c0cb2e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.6.0 +### New features +* N/A + +### Breaking changes +* Project name updated - this will require require re-creating any existing data sources +* Minimum Grafana version updated to 10.0 + +### Bugs squashed +* Resolved an issue where date time formatting was incorrectly handled after Astra updates to support ES datasources +* Resolved an issue where empty results would incorrectly render faux table contents +* Resolved an issue where empty results would not correctly clear previous result state + ## 0.5.1 ### New features * N/A @@ -112,19 +125,19 @@ N/A N/A ### Bugs squashed -* Fixed an issue where the KalDB log UI would fail to render in Grafana 9.X versions -* Fixed an issue where we weren't properly mapping and parsing the dates returned by KalDB +* Fixed an issue where the Astra log UI would fail to render in Grafana 9.X versions +* Fixed an issue where we weren't properly mapping and parsing the dates returned by Astra * Fixed an issue where we still allowed folks to select "PPL" as a query type, despite it not being (currently) supported ## 0.0.2 ### New features -* Initial release of KalDB backend datasource -* Shard count (total, failed) from KalDB explore page +* Initial release of Astra backend datasource +* Shard count (total, failed) from Astra explore page ### Breaking changes -* Elasticsearch is no longer a supported datasource from KalDB explore UI +* Elasticsearch is no longer a supported datasource from Astra explore UI ## 0.0.1 diff --git a/README.md b/README.md index 3f2681f..f248eee 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ To get started [install](https://grafana.com/docs/grafana/latest/plugins/install the Grafana plugins page under "Astra by Slack". Once installed a new datasource type will be available, and Astra will appear in the navigation under Apps. -![Astra explore](src/img/kaldb_explore.png) +![Astra explore](src/img/explore.png) ## Other resources * [Getting started with development](.github/CONTRIBUTING.md#getting-started-with-development) diff --git a/docker-compose.yaml b/docker-compose.yaml index c87b52e..f1de6a6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,7 +2,7 @@ version: '3.0' services: grafana: - container_name: 'slack-kaldb-app' + container_name: 'slack-astra-app' build: context: ./.config args: @@ -10,7 +10,7 @@ services: ports: - 3000:3000/tcp volumes: - - ./dist:/var/lib/grafana/plugins/slack-kaldb-app + - ./dist:/var/lib/grafana/plugins/slack-astra-app - ./provisioning:/etc/grafana/provisioning environment: GF_LOG_MODE: "console file" @@ -19,5 +19,5 @@ services: GF_AUTH_ANONYMOUS_ENABLED: "true" GF_AUTH_ANONYMOUS_ORG_ROLE: "Admin" GF_PATHS_PLUGINS: "/var/lib/grafana/plugins" - GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: "slack-kaldb-app,slack-kaldb-app-backend-datasource" + GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: "slack-astra-app,slack-astra-app-backend-datasource" GF_SERVER_ENABLE_GZIP: "true" diff --git a/go.mod b/go.mod index 188eab0..7ee2076 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/slackhq/slack-kaldb-app +module github.com/slackhq/slack-astra-app go 1.14 diff --git a/package.json b/package.json index febd6a6..b075ec9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "slack-kaldb-app", - "version": "0.5.1", - "description": "Grafana KalDB App", + "name": "slack-astra-app", + "version": "0.6.0", + "description": "Grafana Astra App", "scripts": { "build": "webpack -c ./.config/webpack/webpack.config.ts --env production", "build-go": "mage buildAll && mv dist/gpx* dist/datasource", @@ -16,7 +16,7 @@ "test": "jest --watch --onlyChanged", "test:ci": "jest --passWithNoTests --maxWorkers 4", "typecheck": "tsc --noEmit", - "zip": "zip slack-kaldb-app.zip dist/ -rj" + "zip": "zip slack-astra-app.zip dist/ -rj" }, "author": "Slack", "license": "Apache-2.0", diff --git a/pkg/kaldb/kaldb.go b/pkg/astra/astra.go similarity index 82% rename from pkg/kaldb/kaldb.go rename to pkg/astra/astra.go index 8a6f3f1..10855b1 100644 --- a/pkg/kaldb/kaldb.go +++ b/pkg/astra/astra.go @@ -1,4 +1,4 @@ -package kaldb +package astra import ( "context" @@ -8,11 +8,11 @@ import ( "github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt" "github.com/grafana/grafana-plugin-sdk-go/backend/log" "github.com/grafana/opensearch-datasource/pkg/tsdb" - es "github.com/slackhq/slack-kaldb-app/pkg/kaldb/client" + es "github.com/slackhq/slack-astra-app/pkg/astra/client" ) -// KalDbExecutor represents a handler for handling KalDb datasource request -type KalDbExecutor struct{} +// AstraExecutor represents a handler for handling Astra datasource request +type AstraExecutor struct{} var ( intervalCalculator tsdb.IntervalCalculator @@ -22,14 +22,14 @@ type TsdbQueryEndpoint interface { Query(ctx context.Context, ds *backend.DataSourceInstanceSettings, query *tsdb.TsdbQuery) (*tsdb.Response, error) } -type KalDbDatasource struct { +type AstraDatasource struct { dsInfo *backend.DataSourceInstanceSettings } -func NewKalDbDatasource(settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) { +func NewAstraDatasource(settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) { log.DefaultLogger.Debug("Initializing new data source instance") - return &KalDbDatasource{ + return &AstraDatasource{ dsInfo: &settings, }, nil } @@ -38,7 +38,7 @@ func NewKalDbDatasource(settings backend.DataSourceInstanceSettings) (instancemg // The main use case for these health checks is the test button on the // datasource configuration page which allows users to verify that // a datasource is working as expected. -func (ds *KalDbDatasource) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) { +func (ds *AstraDatasource) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) { res := &backend.CheckHealthResult{} res.Status = backend.HealthStatusOk @@ -50,7 +50,7 @@ func (ds *KalDbDatasource) CheckHealth(ctx context.Context, req *backend.CheckHe // req contains the queries []DataQuery (where each query contains RefID as a unique identifier). // The QueryDataResponse contains a map of RefID to the response for each query, and each response // contains Frames ([]*Frame). -func (ds *KalDbDatasource) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) { +func (ds *AstraDatasource) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) { if len(req.Queries) == 0 { return nil, fmt.Errorf("query contains no queries") } diff --git a/pkg/kaldb/client/client.go b/pkg/astra/client/client.go similarity index 100% rename from pkg/kaldb/client/client.go rename to pkg/astra/client/client.go diff --git a/pkg/kaldb/client/client_test.go b/pkg/astra/client/client_test.go similarity index 100% rename from pkg/kaldb/client/client_test.go rename to pkg/astra/client/client_test.go diff --git a/pkg/kaldb/client/index_pattern.go b/pkg/astra/client/index_pattern.go similarity index 100% rename from pkg/kaldb/client/index_pattern.go rename to pkg/astra/client/index_pattern.go diff --git a/pkg/kaldb/client/index_pattern_test.go b/pkg/astra/client/index_pattern_test.go similarity index 100% rename from pkg/kaldb/client/index_pattern_test.go rename to pkg/astra/client/index_pattern_test.go diff --git a/pkg/kaldb/client/models.go b/pkg/astra/client/models.go similarity index 100% rename from pkg/kaldb/client/models.go rename to pkg/astra/client/models.go diff --git a/pkg/kaldb/client/ppl_request.go b/pkg/astra/client/ppl_request.go similarity index 100% rename from pkg/kaldb/client/ppl_request.go rename to pkg/astra/client/ppl_request.go diff --git a/pkg/kaldb/client/ppl_request_test.go b/pkg/astra/client/ppl_request_test.go similarity index 100% rename from pkg/kaldb/client/ppl_request_test.go rename to pkg/astra/client/ppl_request_test.go diff --git a/pkg/kaldb/client/search_request.go b/pkg/astra/client/search_request.go similarity index 100% rename from pkg/kaldb/client/search_request.go rename to pkg/astra/client/search_request.go diff --git a/pkg/kaldb/client/search_request_test.go b/pkg/astra/client/search_request_test.go similarity index 100% rename from pkg/kaldb/client/search_request_test.go rename to pkg/astra/client/search_request_test.go diff --git a/pkg/kaldb/lucene_handler.go b/pkg/astra/lucene_handler.go similarity index 99% rename from pkg/kaldb/lucene_handler.go rename to pkg/astra/lucene_handler.go index 4581a37..fd5e1db 100644 --- a/pkg/kaldb/lucene_handler.go +++ b/pkg/astra/lucene_handler.go @@ -1,4 +1,4 @@ -package kaldb +package astra import ( "fmt" @@ -8,7 +8,7 @@ import ( "github.com/grafana/grafana-plugin-sdk-go/backend" "github.com/grafana/opensearch-datasource/pkg/tsdb" "github.com/grafana/opensearch-datasource/pkg/utils" - es "github.com/slackhq/slack-kaldb-app/pkg/kaldb/client" + es "github.com/slackhq/slack-astra-app/pkg/astra/client" ) type luceneHandler struct { diff --git a/pkg/kaldb/models.go b/pkg/astra/models.go similarity index 99% rename from pkg/kaldb/models.go rename to pkg/astra/models.go index 041dd0c..12f0058 100644 --- a/pkg/kaldb/models.go +++ b/pkg/astra/models.go @@ -1,4 +1,4 @@ -package kaldb +package astra import ( "github.com/bitly/go-simplejson" diff --git a/pkg/kaldb/ppl_handler.go b/pkg/astra/ppl_handler.go similarity index 94% rename from pkg/kaldb/ppl_handler.go rename to pkg/astra/ppl_handler.go index 0b0b390..4df2723 100644 --- a/pkg/kaldb/ppl_handler.go +++ b/pkg/astra/ppl_handler.go @@ -1,8 +1,8 @@ -package kaldb +package astra import ( "github.com/grafana/grafana-plugin-sdk-go/backend" - es "github.com/slackhq/slack-kaldb-app/pkg/kaldb/client" + es "github.com/slackhq/slack-astra-app/pkg/astra/client" ) type pplHandler struct { diff --git a/pkg/kaldb/ppl_response_parser.go b/pkg/astra/ppl_response_parser.go similarity index 98% rename from pkg/kaldb/ppl_response_parser.go rename to pkg/astra/ppl_response_parser.go index ea44045..5994de0 100644 --- a/pkg/kaldb/ppl_response_parser.go +++ b/pkg/astra/ppl_response_parser.go @@ -1,4 +1,4 @@ -package kaldb +package astra import ( "errors" @@ -10,7 +10,7 @@ import ( "github.com/grafana/grafana-plugin-sdk-go/data" "github.com/grafana/opensearch-datasource/pkg/null" "github.com/grafana/opensearch-datasource/pkg/utils" - es "github.com/slackhq/slack-kaldb-app/pkg/kaldb/client" + es "github.com/slackhq/slack-astra-app/pkg/astra/client" ) type pplResponseParser struct { diff --git a/pkg/kaldb/ppl_response_parser_test.go b/pkg/astra/ppl_response_parser_test.go similarity index 99% rename from pkg/kaldb/ppl_response_parser_test.go rename to pkg/astra/ppl_response_parser_test.go index 064f293..cb9c63f 100644 --- a/pkg/kaldb/ppl_response_parser_test.go +++ b/pkg/astra/ppl_response_parser_test.go @@ -1,4 +1,4 @@ -package kaldb +package astra import ( "encoding/json" @@ -7,7 +7,7 @@ import ( "time" "github.com/grafana/grafana-plugin-sdk-go/data" - es "github.com/slackhq/slack-kaldb-app/pkg/kaldb/client" + es "github.com/slackhq/slack-astra-app/pkg/astra/client" . "github.com/smartystreets/goconvey/convey" ) diff --git a/pkg/kaldb/response_parser.go b/pkg/astra/response_parser.go similarity index 99% rename from pkg/kaldb/response_parser.go rename to pkg/astra/response_parser.go index f44d97a..81ebd4c 100644 --- a/pkg/kaldb/response_parser.go +++ b/pkg/astra/response_parser.go @@ -1,4 +1,4 @@ -package kaldb +package astra import ( "errors" @@ -15,7 +15,7 @@ import ( "github.com/grafana/opensearch-datasource/pkg/null" "github.com/grafana/opensearch-datasource/pkg/tsdb" "github.com/grafana/opensearch-datasource/pkg/utils" - es "github.com/slackhq/slack-kaldb-app/pkg/kaldb/client" + es "github.com/slackhq/slack-astra-app/pkg/astra/client" ) const ( diff --git a/pkg/kaldb/response_parser_test.go_ b/pkg/astra/response_parser_test.go_ similarity index 99% rename from pkg/kaldb/response_parser_test.go_ rename to pkg/astra/response_parser_test.go_ index 872ebd9..0176a8e 100644 --- a/pkg/kaldb/response_parser_test.go_ +++ b/pkg/astra/response_parser_test.go_ @@ -5,7 +5,7 @@ import ( "testing" "time" - es "github.com/slackhq/slack-kaldb-app/pkg/kaldb/client" + es "github.com/slackhq/slack-astra-app/pkg/astra/client" "github.com/grafana/es-open-distro-datasource/pkg/null" "github.com/grafana/grafana-plugin-sdk-go/backend" . "github.com/smartystreets/goconvey/convey" diff --git a/pkg/kaldb/time_series_query.go b/pkg/astra/time_series_query.go similarity index 98% rename from pkg/kaldb/time_series_query.go rename to pkg/astra/time_series_query.go index bd1d32f..bbbcda4 100644 --- a/pkg/kaldb/time_series_query.go +++ b/pkg/astra/time_series_query.go @@ -1,4 +1,4 @@ -package kaldb +package astra import ( "strconv" @@ -7,7 +7,7 @@ import ( "github.com/grafana/grafana-plugin-sdk-go/backend" "github.com/grafana/opensearch-datasource/pkg/tsdb" "github.com/grafana/opensearch-datasource/pkg/utils" - es "github.com/slackhq/slack-kaldb-app/pkg/kaldb/client" + es "github.com/slackhq/slack-astra-app/pkg/astra/client" ) type timeSeriesQuery struct { diff --git a/pkg/kaldb/time_series_query_test.go b/pkg/astra/time_series_query_test.go similarity index 99% rename from pkg/kaldb/time_series_query_test.go rename to pkg/astra/time_series_query_test.go index 487b7ac..c03fc93 100644 --- a/pkg/kaldb/time_series_query_test.go +++ b/pkg/astra/time_series_query_test.go @@ -1,4 +1,4 @@ -package kaldb +package astra import ( "fmt" @@ -7,8 +7,8 @@ import ( "github.com/Masterminds/semver" "github.com/grafana/grafana-plugin-sdk-go/backend" - es "github.com/slackhq/slack-kaldb-app/pkg/kaldb/client" "github.com/grafana/opensearch-datasource/pkg/tsdb" + es "github.com/slackhq/slack-astra-app/pkg/astra/client" . "github.com/smartystreets/goconvey/convey" ) diff --git a/pkg/main.go b/pkg/main.go index 017b810..61936a1 100644 --- a/pkg/main.go +++ b/pkg/main.go @@ -1,11 +1,11 @@ package main import ( + astra "github.com/slackhq/slack-astra-app/pkg/astra" "os" "github.com/grafana/grafana-plugin-sdk-go/backend/datasource" "github.com/grafana/grafana-plugin-sdk-go/backend/log" - "github.com/slackhq/slack-kaldb-app/pkg/kaldb" ) func main() { @@ -14,10 +14,10 @@ func main() { // to exit by itself using os.Exit. Manage automatically manages life cycle // of datasource instances. It accepts datasource instance factory as first // argument. This factory will be automatically called on incoming request - // from Grafana to create different instances of KalDbDatasource (per datasource + // from Grafana to create different instances of AstraDatasource (per datasource // ID). When datasource configuration changed Dispose method will be called and - // new datasource instance created using NewKalDbDatasource factory. - if err := datasource.Manage("slack-kaldb-app-backend-datasource", kaldb.NewKalDbDatasource, datasource.ManageOpts{}); err != nil { + // new datasource instance created using NewAstraDatasource factory. + if err := datasource.Manage("slack-astra-app-backend-datasource", astra.NewAstraDatasource, datasource.ManageOpts{}); err != nil { log.DefaultLogger.Error(err.Error()) os.Exit(1) } diff --git a/provisioning/datasources/automatic.yml b/provisioning/datasources/automatic.yml index 25bba7d..e9c815b 100644 --- a/provisioning/datasources/automatic.yml +++ b/provisioning/datasources/automatic.yml @@ -1,13 +1,12 @@ apiVersion: 1 deleteDatasources: - - name: KalDB + - name: Astra orgId: 1 datasources: - - name: KalDB Query [ES] + - name: Astra Query [ES] type: elasticsearch - access: proxy url: "host.docker.internal:8081" password: user: @@ -18,8 +17,7 @@ datasources: withCredentials: isDefault: true jsonData: - timeField: "@timestamp" - esVersion: 7.0.0 + timeField: "_timesinceepoch" maxConcurrentShardRequests: 5 logMessageField: "_source" logLevelField: "" diff --git a/src/README.md b/src/README.md index f390408..61bccfa 100644 --- a/src/README.md +++ b/src/README.md @@ -1,8 +1,8 @@ -# KalDB Grafana App +# Astra Grafana App -This Grafana plugin adds support for [KalDB](https://github.com/slackhq/kaldb), and includes both a datasource and +This Grafana plugin adds support for [Astra](https://github.com/slackhq/astra), and includes both a datasource and simplified explore interface. To get started [install](https://grafana.com/docs/grafana/latest/plugins/installation/) this app, then enable it from -the Grafana plugins page under "KalDB by Slack". Once installed a new datasource type will be available, and the KalDB +the Grafana plugins page under "Astra by Slack". Once installed a new datasource type will be available, and the Astra explore icon will appear on the left side of the Grafana UI. diff --git a/src/datasource/OpenSearchResponse.ts b/src/datasource/OpenSearchResponse.ts index d3adb0c..84f9ca4 100644 --- a/src/datasource/OpenSearchResponse.ts +++ b/src/datasource/OpenSearchResponse.ts @@ -486,10 +486,6 @@ export class OpenSearchResponse { doc['level'] = doc[logLevelField]; } - // The hit. field is in fractional seconds, but we expect it to be in milliseconds later in rendering - // NOTE: This may change in the future to a different format - doc['_timesinceepoch'] = doc['_timesinceepoch'] * 1000; - series.add(doc); } if (isLogsRequest) { @@ -673,14 +669,14 @@ type Doc = { _index: string; _score?: any; _source?: any; - _timesinceepoch: number; + _timesinceepoch: any; }; /** * Flatten the docs from response mainly the _source part which can be nested. This flattens it so that it is one level * deep and the keys are: `level1Name.level2Name...`. Also returns list of all properties from all the docs (not all * docs have to have the same keys). - * @param hits - The hits from KalDB + * @param hits - The hits from Astra */ const flattenHits = (hits: Doc[]): { docs: Array>; propNames: string[] } => { const docs: any[] = []; diff --git a/src/datasource/components/Logs/LogsCell.tsx b/src/datasource/components/Logs/LogsCell.tsx index 3a9e1ee..2ee9ad4 100644 --- a/src/datasource/components/Logs/LogsCell.tsx +++ b/src/datasource/components/Logs/LogsCell.tsx @@ -191,7 +191,7 @@ const DocumentCell = (log: Log, style: any, rowIndex: number, expanded: boolean, ) -const TimestampCell = (timestamp: number, style: any, rowIndex: number, expandedRows: boolean[], onClick: ((index: number) => void)) => { +const TimestampCell = (timestamp: string, style: any, rowIndex: number, expandedRows: boolean[], onClick: ((index: number) => void)) => { const getFoldIcon = () => { if (expandedRows[rowIndex]) { return 'angle-down'; diff --git a/src/datasource/components/Logs/LogsTable.tsx b/src/datasource/components/Logs/LogsTable.tsx index 6946fef..11b5f34 100644 --- a/src/datasource/components/Logs/LogsTable.tsx +++ b/src/datasource/components/Logs/LogsTable.tsx @@ -26,7 +26,7 @@ interface LogsTableProps { logs: Log[]; timeField: string; columns: LogColumn[]; - timestamps: number[]; + timestamps: string[]; expandedRows: boolean[]; datasourceUid: string; datasourceName: string; diff --git a/src/datasource/components/Logs/LogsView.tsx b/src/datasource/components/Logs/LogsView.tsx index 46c3530..589bf69 100644 --- a/src/datasource/components/Logs/LogsView.tsx +++ b/src/datasource/components/Logs/LogsView.tsx @@ -7,7 +7,7 @@ import LogsTable from 'datasource/components/Logs/LogsTable' interface LogsViewProps { logs: Log[]; timeField: string; - timestamps: number[]; + timestamps: string[]; datasourceUid: string; datasourceName: string; datasourceField: string; diff --git a/src/datasource/configuration/KalDbDetails.test.tsx b/src/datasource/configuration/AstraDetails.test.tsx similarity index 93% rename from src/datasource/configuration/KalDbDetails.test.tsx rename to src/datasource/configuration/AstraDetails.test.tsx index ce2ede3..d4b3a6e 100644 --- a/src/datasource/configuration/KalDbDetails.test.tsx +++ b/src/datasource/configuration/AstraDetails.test.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { mount } from 'enzyme'; -import { KalDbDetails } from './KalDbDetails'; +import { AstraDetails } from './AstraDetails'; import { createDefaultConfigOptions } from './mocks'; import { LegacyForms } from '@grafana/ui'; import { Flavor, OpenSearchOptions } from '../types'; @@ -10,12 +10,12 @@ const { Select, Switch } = LegacyForms; describe('OpenSearchDetails', () => { it('should render without error', () => { - mount( {}} value={createDefaultConfigOptions()} />); + mount( {}} value={createDefaultConfigOptions()} />); }); it.skip('should change database on interval change when not set explicitly', () => { const onChangeMock = jest.fn(); - const wrapper = mount(); + const wrapper = mount(); const selectEl = wrapper.find({ label: 'Pattern' }).find(Select); selectEl.props().onChange({ value: 'Daily', label: 'Daily' }, { action: 'select-option', option: undefined }); @@ -27,7 +27,7 @@ describe('OpenSearchDetails', () => { const onChangeMock = jest.fn(); const options = createDefaultConfigOptions(); options.database = '[logstash-]YYYY.MM.DD.HH'; - const wrapper = mount(); + const wrapper = mount(); const selectEl = wrapper.find({ label: 'Pattern' }).find(Select); selectEl.props().onChange({ value: 'Monthly', label: 'Monthly' }, { action: 'select-option', option: undefined }); @@ -41,7 +41,7 @@ describe('OpenSearchDetails', () => { const onChangeMock = jest.fn(); const options = createDefaultConfigOptions(); options.jsonData.pplEnabled = false; - const wrapper = mount(); + const wrapper = mount(); const switchEl = wrapper.find({ label: 'PPL enabled' }).find(Switch); const event = { @@ -123,7 +123,7 @@ describe('OpenSearchDetails', () => { version: tc.version, }, }; - const wrapper = mount(); + const wrapper = mount(); wrapper.setProps({ onChange: onChangeMock, diff --git a/src/datasource/configuration/KalDbDetails.tsx b/src/datasource/configuration/AstraDetails.tsx similarity index 98% rename from src/datasource/configuration/KalDbDetails.tsx rename to src/datasource/configuration/AstraDetails.tsx index 94e4496..f28d1f6 100644 --- a/src/datasource/configuration/KalDbDetails.tsx +++ b/src/datasource/configuration/AstraDetails.tsx @@ -19,12 +19,12 @@ type Props = { value: DataSourceSettings; onChange: (value: DataSourceSettings) => void; }; -export const KalDbDetails = (props: Props) => { +export const AstraDetails = (props: Props) => { const { value, onChange } = props; return ( <> -

KalDB details

+

Astra details

@@ -35,7 +35,7 @@ export const KalDbDetails = (props: Props) => { label="Index name" value={value.jsonData.database || ''} onChange={jsonDataChangeHandler('database', value, onChange)} - placeholder={'es-index-name'} + placeholder={'_all'} required />
diff --git a/src/datasource/configuration/ConfigEditor.test.tsx b/src/datasource/configuration/ConfigEditor.test.tsx index 5fe38fc..8c360d5 100644 --- a/src/datasource/configuration/ConfigEditor.test.tsx +++ b/src/datasource/configuration/ConfigEditor.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; import { ConfigEditor } from './ConfigEditor'; import { DataSourceHttpSettings } from '@grafana/ui'; -import { KalDbDetails } from './KalDbDetails'; +import { AstraDetails } from './AstraDetails'; import { LogsConfig } from './LogsConfig'; import { createDefaultConfigOptions } from './mocks'; import { render } from '@testing-library/react'; @@ -15,7 +15,7 @@ describe('ConfigEditor', () => { it('should render all parts of the config', () => { const wrapper = shallow( {}} options={createDefaultConfigOptions()} />); expect(wrapper.find(DataSourceHttpSettings).length).toBe(1); - expect(wrapper.find(KalDbDetails).length).toBe(1); + expect(wrapper.find(AstraDetails).length).toBe(1); expect(wrapper.find(LogsConfig).length).toBe(1); }); @@ -31,9 +31,9 @@ describe('ConfigEditor', () => { render( { - expect(options.jsonData.flavor).toBe('kaldb'); + expect(options.jsonData.flavor).toBe('astra'); expect(options.jsonData.version).toBe('0.0.1'); - expect(options.jsonData.timeField).toBe('@timestamp'); + expect(options.jsonData.timeField).toBe('_timesinceepoch'); }} options={options} /> diff --git a/src/datasource/configuration/ConfigEditor.tsx b/src/datasource/configuration/ConfigEditor.tsx index cfb1ef4..3aa0eb7 100644 --- a/src/datasource/configuration/ConfigEditor.tsx +++ b/src/datasource/configuration/ConfigEditor.tsx @@ -2,7 +2,7 @@ import React, { useEffect } from 'react'; import { DataSourceHttpSettings } from '@grafana/ui'; import { DataSourcePluginOptionsEditorProps } from '@grafana/data'; import { OpenSearchOptions } from '../types'; -import { KalDbDetails } from './KalDbDetails'; +import { AstraDetails } from './AstraDetails'; import { LogsConfig } from './LogsConfig'; import { DataLinks } from './DataLinks'; import { coerceOptions, isValidOptions } from './utils'; @@ -34,7 +34,7 @@ export const ConfigEditor = (props: Props) => { renderSigV4Editor={} /> - + ): DataSourceSettings => { - const flavor = options.jsonData.flavor || Flavor.KalDB; + const flavor = options.jsonData.flavor || Flavor.Astra; const version = valid(options.jsonData.version) || AVAILABLE_VERSIONS.find(v => v.value.flavor === flavor)?.value.version || @@ -16,7 +16,8 @@ export const coerceOptions = ( ...options, jsonData: { ...options.jsonData, - timeField: options.jsonData.timeField || '@timestamp', + database: options.jsonData.database || '_all', + timeField: options.jsonData.timeField || '_timesinceepoch', version, flavor, maxConcurrentShardRequests: @@ -53,16 +54,16 @@ interface Version { export const AVAILABLE_VERSIONS: Array> = [ { - label: 'KalDB 0.0.x', + label: 'Astra 0.0.1-alpha', value: { - flavor: Flavor.KalDB, + flavor: Flavor.Astra, version: '0.0.1', }, }, ]; export const AVAILABLE_FLAVORS: Array> = [ - { label: 'KalDB', value: Flavor.KalDB }, + { label: 'Astra', value: Flavor.Astra }, { label: 'OpenSearch', value: Flavor.OpenSearch }, { label: 'ElasticSearch', value: Flavor.Elasticsearch }, ]; diff --git a/src/datasource/img/logo.svg b/src/datasource/img/logo.svg index 6ca6cb3..b79e1b7 100644 --- a/src/datasource/img/logo.svg +++ b/src/datasource/img/logo.svg @@ -1 +1,26 @@ - + + + + + + + + + + + + + + + + + + + + + diff --git a/src/datasource/plugin.json b/src/datasource/plugin.json index 251e900..f158f40 100644 --- a/src/datasource/plugin.json +++ b/src/datasource/plugin.json @@ -1,20 +1,20 @@ { "type": "datasource", - "name": "KalDB", - "id": "slack-kaldb-app-backend-datasource", + "name": "Astra", + "id": "slack-astra-app-backend-datasource", "category": "logging", "alerting": true, "annotations": true, "metrics": true, "logs": true, "backend": true, - "executable": "gpx_slack_kaldb_app_datasource_backend", + "executable": "gpx_slack_astra_app_datasource_backend", "info": { - "description": "Grafana KalDB App", + "description": "Grafana Astra App", "author": { "name": "Slack" }, - "keywords": ["KalDB"], + "keywords": ["Astra"], "logos": { "small": "img/logo.svg", "large": "img/logo.svg" diff --git a/src/datasource/types.ts b/src/datasource/types.ts index 00e2d21..ee80878 100644 --- a/src/datasource/types.ts +++ b/src/datasource/types.ts @@ -92,7 +92,7 @@ export enum QueryType { export enum Flavor { Elasticsearch = 'elasticsearch', OpenSearch = 'opensearch', - KalDB = 'kaldb', + Astra = 'astra', } export interface ValueFrequency { diff --git a/src/img/kaldb_explore.png b/src/img/explore.png similarity index 100% rename from src/img/kaldb_explore.png rename to src/img/explore.png diff --git a/src/img/logo.svg b/src/img/logo.svg index 6ca6cb3..97a8cfd 100644 --- a/src/img/logo.svg +++ b/src/img/logo.svg @@ -1 +1,26 @@ - + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/legacy/config.ts b/src/legacy/config.ts index eb9bcd9..f5243a9 100644 --- a/src/legacy/config.ts +++ b/src/legacy/config.ts @@ -1,7 +1,7 @@ import { PluginMeta } from '@grafana/data'; -export class KalDbConfigCtrl { - static template = '

KalDB Config

'; +export class AstraConfigCtrl { + static template = '

Astra Config

'; appEditCtrl: any; appModel?: PluginMeta; diff --git a/src/pages/explore.tsx b/src/pages/explore.tsx index 92f9de8..b0f0906 100644 --- a/src/pages/explore.tsx +++ b/src/pages/explore.tsx @@ -45,7 +45,7 @@ import { DARK_THEME_BACKGROUND, DARK_THEME_HIGHLIGHTED_BACKGROUND, LIGHT_THEME_B import AutoSizer from 'react-virtualized-auto-sizer' /** - * The main explore component for KalDB, using the new Grafana scenes implementation. + * The main explore component for Astra, using the new Grafana scenes implementation. * * @see {@link https://grafana.github.io/scenes/ | Grafana scenes documentation} * @see {@link https://developers.grafana.com/ui/latest/index.html?path=/story/docs-overview-intro--page | Grafana UI documentation} @@ -53,7 +53,7 @@ import AutoSizer from 'react-virtualized-auto-sizer' const dataSourceVariable = new DataSourceVariable({ name: 'datasource', - pluginId: 'slack-kaldb-app-backend-datasource', + pluginId: 'slack-astra-app-backend-datasource', hide: VariableHide.hideVariable, }); @@ -79,7 +79,7 @@ interface FieldStatsState extends SceneObjectState { interface LogsState extends SceneObjectState { logs: Log[]; - timestamps: number[]; + timestamps: string[]; loading: boolean; totalCount: number; totalFailed: number; @@ -144,12 +144,12 @@ class ResultStats extends SceneObjectBase { } } -interface KaldbQueryState extends SceneObjectState { +interface AstraQueryState extends SceneObjectState { query: string; loading: boolean; } -const KaldbQueryRenderer = ({ model }: SceneComponentProps) => { +const AstraQueryRenderer = ({ model }: SceneComponentProps) => { const { loading } = model.useState(); return ( @@ -185,7 +185,7 @@ const KaldbQueryRenderer = ({ model }: SceneComponentProps) => { ); }; -const KalDBFieldsList = (fields: Field[], topTenMostPopularFields: Field[], datasourceUserConfig: DatasourceUserConfig) => { +const AstraFieldsList = (fields: Field[], topTenMostPopularFields: Field[], datasourceUserConfig: DatasourceUserConfig) => { const getIcon = (field: Field): string => { if (field.type === 'string') { return 'fa fas fa-font'; @@ -341,7 +341,7 @@ const KalDBFieldsList = (fields: Field[], topTenMostPopularFields: Field[], data ); }; -const KalDBFieldsRenderer = ({ model }: SceneComponentProps) => { +const AstraFieldsRenderer = ({ model }: SceneComponentProps) => { const { fields, topTenMostPopularFields, visible, loading, datasourceUserConfig } = model.useState(); const getFoldIcon = () => { @@ -377,7 +377,7 @@ const KalDBFieldsRenderer = ({ model }: SceneComponentProps) => {
- {visible ? KalDBFieldsList(fields, topTenMostPopularFields, datasourceUserConfig) : null} + {visible ? AstraFieldsList(fields, topTenMostPopularFields, datasourceUserConfig) : null} )} @@ -385,7 +385,7 @@ const KalDBFieldsRenderer = ({ model }: SceneComponentProps) => { }; class FieldStats extends SceneObjectBase { - static Component = KalDBFieldsRenderer; + static Component = AstraFieldsRenderer; constructor(state?: Partial) { super({ fields: [], @@ -427,7 +427,7 @@ class FieldStats extends SceneObjectBase { }; } -const KalDBLogsRenderer = ({ model }: SceneComponentProps) => { +const AstraLogsRenderer = ({ model }: SceneComponentProps) => { const { logs, loading, timestamps, datasourceUserConfig } = model.useState(); // TODO: This should be whatever the user set @@ -475,8 +475,8 @@ const KalDBLogsRenderer = ({ model }: SceneComponentProps) => { ); } -class KalDBLogs extends SceneObjectBase { - static Component = KalDBLogsRenderer; +class AstraLogs extends SceneObjectBase { + static Component = AstraLogsRenderer; constructor(state?: Partial) { super({ logs: [], @@ -495,7 +495,7 @@ class KalDBLogs extends SceneObjectBase { }); } - setTimestamps = (timestamps: number[]) => { + setTimestamps = (timestamps: string[]) => { this.setState({ timestamps: timestamps, }); @@ -529,10 +529,10 @@ class KalDBLogs extends SceneObjectBase { -class KaldbQuery extends SceneObjectBase { - static Component = KaldbQueryRenderer; +class AstraQuery extends SceneObjectBase { + static Component = AstraQueryRenderer; - constructor(state?: Partial) { + constructor(state?: Partial) { super({ query: '', loading: false, @@ -594,9 +594,9 @@ class KaldbQuery extends SceneObjectBase { const histogramNodeStats = new NodeStats(); const resultsCounter = new ResultStats(); -const queryComponent = new KaldbQuery(); +const queryComponent = new AstraQuery(); const fieldComponent = new FieldStats(); -const logsComponent = new KalDBLogs(); +const logsComponent = new AstraLogs(); const getExploreScene = () => { return new EmbeddedScene({ @@ -692,18 +692,28 @@ const getExploreScene = () => { }; /** - * Parse the log data returned from KalDB and extract the relevant information + * Parse the log data returned from Astra and extract the relevant information * to our various SceneObject's */ const parseAndExtractLogData = (data: DataFrame[]) => { + logsComponent.setTotalCount(-1); + logsComponent.setTotalFailed(-1); + fieldComponent.setFields([]); + fieldComponent.setTopTenMostPopularFields([]); + logsComponent.setLogs([]); + logsComponent.setTimestamps([]); + // Set log count - if (data.length > 0 && data[0].meta['shards']) { + if (data.length === 2 && data[0].meta['shards']) { logsComponent.setTotalCount(data[0].meta['shards'].total); logsComponent.setTotalFailed(data[0].meta['shards'].failed); + } else if (data.length > 0 && data[0].meta['shards']) { + logsComponent.setTotalCount(0); + logsComponent.setTotalFailed(data[0].meta['shards'].failed); } // Set field names, the most popular fields, and calculates the frequency of the most common values - if (data.length > 0 && data[0].fields.length > 0) { + if (data.length === 2 && data[0].fields.length > 0) { const currentDataSource = dataSourceVariable ['getDataSourceTypes']() // This is gross, but we need to access this private property and this is the only real typesafe way to do so in TypeScript .filter((ele) => ele.name === dataSourceVariable.getValueText())[0]; @@ -729,7 +739,7 @@ const parseAndExtractLogData = (data: DataFrame[]) => { let mappedFields: Map = new Map(); let reconstructedLogs: Log[] = [...Array(data[0].length)]; - let timestamps: number[] = []; + let timestamps: string[] = []; for (let unmappedField of data[0].fields) { // TODO: Ignore the logMessageField (e.g. _source) for now. We'll likely need to revisit this @@ -870,7 +880,8 @@ const histogramPanel = PanelBuilders.timeseries() const histogramResultTransformation: CustomTransformOperator = () => (source: Observable) => { return source.pipe( map((data: DataFrame[]) => { - if (data.length > 0 && data[0].meta['shards']) { + resultsCounter.setResults(-1); + if (data.length === 2 && data[0].meta['shards']) { let counter = 0; // In Grafana 9, the values live in `values['buffer']`. @@ -906,7 +917,7 @@ const explorePage = new SceneAppPage({ from: 'now-15m', to: 'now', }), - url: '/a/slack-kaldb-app', + url: '/a/slack-astra-app', getScene: getExploreScene, }); diff --git a/src/plugin.json b/src/plugin.json index ed18375..564424a 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -1,20 +1,20 @@ { "$schema": "https://raw.githubusercontent.com/grafana/grafana/master/docs/sources/developers/plugins/plugin.schema.json", "type": "app", - "name": "KalDB", - "id": "slack-kaldb-app", - "executable": "gpx_slack_kaldb_app_datasource_backend", + "name": "Astra", + "id": "slack-astra-app", + "executable": "gpx_slack_astra_app_datasource_backend", "info": { - "description": "Grafana KalDB App", + "description": "Grafana Astra App", "author": { "name": "Slack" }, - "keywords": ["KalDB"], + "keywords": ["Astra"], "logos": { "small": "img/logo.svg", "large": "img/logo.svg" }, - "links": [{ "name": "Github", "url": "https://github.com/slackhq/kaldb" }], + "links": [{ "name": "Github", "url": "https://github.com/slackhq/astra" }], "screenshots": [], "version": "%VERSION%", "updated": "%TODAY%" @@ -24,7 +24,7 @@ { "type": "page", "name": "Explore", - "path": "/a/slack-kaldb-app", + "path": "/a/slack-astra-app", "icon": "compass", "role": "Viewer", "addToNav": true, @@ -39,8 +39,8 @@ ], "dependencies": { - "grafanaDependency": ">=9.5.0", - "grafanaVersion": "9.5.0", + "grafanaDependency": ">=10.0.0", + "grafanaVersion": "10.0.0", "plugins": [] } } diff --git a/src/types.ts b/src/types.ts index f9354c1..c88b27f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1 +1 @@ -export interface KalDbSettings {} +export interface AstraSettings {}