Commit Graph

67 Commits

Author SHA1 Message Date
Ivana Huckova
494d169980
Elasticsearch: Fix legend for alerting, expressions and previously frontend queries (#84485)
* Elasticsearch: Fix legend for alerting, expressions and previously frontend queries

* Add comment

* Update comment
2024-03-18 18:01:33 +01:00
Ivana Huckova
f2936d6695
Elasticsearch: Fix creating of legend so it is backward compatible with frontend produced frames (#81708)
* Elasticsearch: Fix creating of legend so it is backward compatible with frontend produced frames

* Update tests
2024-02-02 12:47:45 +01:00
Ivana Huckova
759c088ac5
Elasticsearch: Fix showing of logs when __source is log message field (#80804)
Elasticsearch: Fix showing of logs whe __source is log message field
2024-01-19 10:28:08 +01:00
Ivana Huckova
28f4c3ed44
Elasticsearch: Fix processing of raw_data with not-recognized time format (#78262)
* Elasticsearch: Fix non-standard time field in raw data queries

* Update snapshot tests

* Refactor
2023-11-20 12:01:41 +01:00
Ivana Huckova
a1718aafce
Elasticsearch: Add error source for DataQuery (#77386)
* WIP

* Refactor, plus update source of error in response_parser

* Adjust test

* Use methods and httpclient from errorsource

* Update pkg/tsdb/elasticsearch/data_query.go

Co-authored-by: Scott Lepper <scott.lepper@gmail.com>

* Return nil error

* Fix test

* Fix integration test

---------

Co-authored-by: Scott Lepper <scott.lepper@gmail.com>
2023-11-06 11:36:39 +01:00
Marcus Efraimsson
e4c1a7a141
Tracing: Standardize on otel tracing (#75528) 2023-10-03 14:54:20 +02:00
Ivana Huckova
c40bc0665b
Elasticsearch: Add instrumentation for elasticsearch_plugin_parse_response_duration_seconds (#75628)
* Elasticsearch: Add instrumentation for elasticsearch_plugin_parse_response_duration_seconds

* Update error tracking
2023-09-28 18:38:14 +03:00
Ivana Huckova
4f0b31d21b
Elasticsearch: Add tracing to data source (#74750)
* Elasticsearch: Add tracing do data source

* Fix tests

* Address feedback

* Update pkg/tsdb/elasticsearch/response_parser.go

Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>

* Update pkg/tsdb/elasticsearch/response_parser.go

Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>

* Track error across both spans

* Add span for decoding of response

* Fix test

* Update setting of errors + fix test

---------

Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>
2023-09-18 10:49:12 +02:00
Ivana Huckova
49bd93aa2b
Elasticsearch: Adjust logging to follow convention (#74554)
* Elasticsearch: Adjust naming in logging according to convention

* Log response parsing per response

* Update

* Fix logging of errors when no response

* Add path to error loggigng

* Update pkg/tsdb/elasticsearch/response_parser.go
2023-09-07 18:15:24 +02:00
Ivana Huckova
51391a762b
Elasticsearch: Improve backend instrumentation of QueryData calls (#74172)
* Elasticsearch: Improve backend instrumentation of QueryData calls

* Add fromAlert

* Fix tests, move logger and context to struct

* Add instrumentation for processing response

* Move log for sending request closer to sending request

* Update

* Fix logging, improved messages, fix printing of queries

* Update log text

* Fix tests

* Fix lint

* Update logging to follow our guidelines

* Remove key-value pairs from logs that are going to be passed from instrumentation

* Update pkg/tsdb/elasticsearch/elasticsearch.go
2023-09-07 13:54:16 +02:00
Sven Grossmann
4c9469fc9e
Elastic: Add id field to Elastic responses to allow permalinking (#73382)
* add `id` field to elasticsearch

* add comment

* slightly better perf

* only add `id` to logs frames

* only add `id` for logs responses

* concat `index` and `id`

* change snapshot generation to false

* use better loop

* fix tests

* moved up
2023-08-18 11:39:58 +02:00
Shirley
c1f6b91ea9
Elasticsearch: Fix multiple max depth flatten of multi-level objects (#70302) 2023-07-14 11:48:00 +02:00
Ivana Huckova
dbbbc46351
Elasticsearch: Fix passing of limit and datalinks to logs data frame (#68554)
* Elasticsearch: Fix passing of limit and datalinks to logs data frame

* Update public/app/core/logsModel.ts

Co-authored-by: François Massot <francois.massot@gmail.com>

---------

Co-authored-by: François Massot <francois.massot@gmail.com>
2023-05-17 14:28:32 +02:00
Ivana Huckova
95cf598423
Elasticsearch: Fix processing of logs with not-recognized time format (#67767)
* Elasticsearch: Fix parsing of invalid time

* Fix lint

* Add more test data to data.js

* Add tests

* Fix lint

* Update pkg/tsdb/elasticsearch/client/search_request.go
2023-05-04 19:33:00 +02:00
Ivana Huckova
e2e243d1b6
Elasticsearch: Fix processing of duplicated metric types and field (#66973)
* Elasticsearch: Fix processing of duplicated metric types and field

* Fix lint

* Fix linting
2023-04-24 17:26:04 +02:00
Ivana Huckova
3e4eb9c93e
Elasticsearch: Fix legend generated on backend (#66039)
* Elasticsearch: Fix legend

* Remove comments

* fix adding name to config

* Fix lint
2023-04-11 13:29:38 +02:00
Ivana Huckova
ae0f9fc44f
Elasticsearch: Fix processing of response with multiple group by for alerting (#65165)
* Elasticsearch: Fix processing of response with multiple group by on backend

* Remove unused param from createFields

* Switch comments
2023-03-22 18:53:09 +02:00
Gábor Farkas
6d5242e54c
elasticsearch: backend: better timestamp parsing (#64681)
* elasticsearch: backend: better timestamp parsing

* refactor
2023-03-22 09:52:55 +01:00
Ivana Huckova
0740d4e911
Elasticsearch: Fix top metrics with terms in backend (#65063)
* Elasticsearch: Fix top metrics with terms in backend

* Refactor to remove cyclomatic complexity
2023-03-22 09:36:43 +01:00
Gábor Farkas
335bcd1e4e
elasticsearch: more robust field order (#65102) 2023-03-21 12:44:10 +00:00
Ivana Huckova
a416235e8f
Elasticsearch: Fix processing of percentiles on backend (#64540)
* Elasticsearch: Fix processing of percentiles on backend

* Remove redundant logic as we do this in addMetricValue

* Refactor for less cyclomatic complexity

* Remove changes in createFieldsFromPropKeys
2023-03-20 16:32:19 +01:00
Ivana Huckova
d6eea0c7b5
Elasticsearch: Fix histogram fields to be filterale when processed trough backend (#64514)
* Elasticsearch: Fix histogram fields to be filterale when processed trough backend

* Simplify test and reuse logic
2023-03-13 10:11:18 +01:00
Ivana Huckova
424e33146c
Elasticsearch: Reintroduce log tests from frontend (#64521)
* Elasticsearch: Reintroduce log tests from frontend

* Fix linting
2023-03-09 11:20:36 -05:00
Ivana Huckova
bd0fa79542
Elasticsearch: Add log highlight processing on backend (#63924)
* Elasticsearch: Add highlight for logs

* Fix running of queries trough backend only when shouldRunTroughBackend

* Fix incorrect json in test string

* Address feedback

* Keep order of words same
2023-03-09 13:34:53 +01:00
Ivana Huckova
aa123e0d50
Elasticsearch: Fix where name of frame is set (#64233)
* Elasticsearch: Use displayName field for naming

* Change solution to frame.Name to be backward compatible

* Fix snapshot tests

* Use Time and Value for time and value fields

* Use variables from grafana-plugin-sdk-go for name
2023-03-08 13:32:01 +01:00
Ivana Huckova
3bd7217aa2
Elasticsearch: Remove _source field when processing raw data on backend (#64119)
* Elasticsearch: Remove _source field when processing raw data on backend

* Update snapshot test
2023-03-07 13:56:34 +01:00
Ivana Huckova
adda7819e9
Elasticsearch: Implement processing of raw document query results in backend (#63932) 2023-03-02 09:50:54 +01:00
Ivana Huckova
d258c8ef8a
Elasticsearch: Implement processing of logs query results in backend (#63647)
* Elasticsearch: Add processing of logs query to backend

* Add and fix tests

* Add snapshot tests

* Fix test in ES client

* Small updates, remove redundant logic

* Refactor setPreferredVisType to improve readability
2023-03-01 05:50:56 -05:00
Ivana Huckova
89b3663a23
Elasticsearch: Add processing for raw data to backend (#63208)
* WIP

* WIP

* Refactor

* Add tests

* Cleanup

* Fix whitespace

* Fix test and lint

* In snapshot tests update counter to be number

* Add boolean value for snapshot testing

* Update pkg/tsdb/elasticsearch/response_parser.go

Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>

* Update pkg/tsdb/elasticsearch/response_parser.go

Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>

* Use generic to reuse logic when creating fields

* Use nullable fields

* Fix lint

* WIP (#63272)

wip

* Fix snapshot test after we changed field types to nullable

---------

Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>
2023-02-22 13:28:43 +01:00
Gábor Farkas
d9fd807375
Elasticsearch: Fix consistent label order in alerting (#62497)
elasticsearch: backend: sort label-values
2023-02-02 09:03:18 +01:00
Serge Zaitsev
0bf4093005
Chore: Fix goimports grouping (#62428)
* fix goimports order

* fix goimports order
2023-01-30 08:50:27 +00:00
Gábor Farkas
88119ad6c3
Elasticsearch: Support nested aggregation (#62301)
* Add nested query support

* Add nested support for alerts

* update nested aggregation

* cleanup types

* Add nested integration test

* Move aggdef to nested

* fixed merge conflict

* fixed lint warning

* mark nested-mode experimental

---------

Co-authored-by: Ethan Gallant <ethan@ziax.com>
Co-authored-by: Ethan J. Gallant <ethan.gallant@acquia.com>
2023-01-27 16:18:36 +01:00
Ruud van der Weijde
b44df6c8d1
ElasticSearch: Improve ES error handling message (#61471)
Look for 'caused_by.reason' in ES error response

When the ES response does not contain `reason` or `root_cause[0].reason`
is empty, there is no information for the user to know what is going
wrong.

An example of the error message after this change:
```
Failed to evaluate queries and expressions: failed to execute query A: Trying to create too many buckets. Must be less than or equal to: [65536] but this number of buckets was exceeded. This limit can be set by changing the [search.max_buckets] cluster level setting.
```

Related to https://github.com/grafana/grafana/issues/61246
2023-01-20 11:46:31 +01:00
Gábor Farkas
12c4098bcd
elastic: backend: handle naming bucket_scripts (#60460) 2023-01-04 15:26:57 +01:00
Ivana Huckova
a1ef3d77f2
Elasticsearch: Use constants for default values and types (#60673) 2022-12-22 15:08:15 +01:00
Gábor Farkas
5633843f76
Elasticsearch: backend: do not set name for time-fields (#60169)
elastic: backend: improve field-naming
2022-12-13 13:19:03 +01:00
Gábor Farkas
3172d8dd9b
elastic: response parser: simplify code (#59782)
elastic: simplify code
2022-12-12 16:00:15 +01:00
Gábor Farkas
b8b2de1ac4
elastic: remove unused debug-code (#59712)
* elastic: remove unused debug-code

* removed unused structs
2022-12-05 04:21:15 -05:00
Gábor Farkas
0491c19712
elastic: backend-mode: fix trimEdges functionality (#56985) 2022-10-19 10:40:42 +02:00
Jorge Luis Betancourt
e4f2006cce
Elasticsearch: Fix calculation of trimEdges (#56148)
* Elasticsearch: Fix calculation of trimEdges

When a value of trimEdges is set greater than 1 we need to drop both the
first and last sample of the data from the response.

* Elasticsearch: Fix reading trimEdges from the query settings

Currently the trimEdges property in the JSON panel is stored as a string
and not directly as a number.

This caused that the reading of the value failed in the go backend
because the simplejson.Int() method doesn't properly handle this case.
This failure when decoding the value goes unnoticed because of the early
return causing the trimEdges configuration to be ignored.

* Refactor castToInt to also return an error

Add a new test case that sets the `trimEdges` property as a quoted
number.
2022-10-14 12:53:12 +02:00
Marcus Efraimsson
baab021fec
Chore: Refactor usage of legacy data contracts (#41218)
Refactor usage of legacy data contracts. Moves legacy data contracts 
to pkg/tsdb/legacydata package.
Refactor pkg/expr to be a proper service/dependency that can be provided 
to wire to remove some unneeded dependencies to SSE in ngalert and other places.
Refactor pkg/expr to not use the legacydata,RequestHandler and use 
backend.QueryDataHandler instead.
2021-11-10 11:52:16 +01:00
Dimitris Sotirakis
12320dda3c
Elasticsearch: Fix metric names for alert queries (#38546)
* Export fieldName to var

* Add empty string as frame name
2021-08-26 09:20:38 +02:00
Dimitris Sotirakis
1aeafa34d1
Elasticsearch: Fix metric names for alert queries (#37871)
* Use props names as metrics names

* Make aliases work
2021-08-16 14:45:20 +03:00
Dimitris Sotirakis
0df1b33d71
Plugins: Migrate Elasticsearch to backend plugin SDK (#36132)
* Migrate Elasticsearch to backend plugin SDK

* Fix linting

* Move away from Convey!

* Rebase commit

* Small logger fix

* Fixes according to reviewer's comments

* Fixes according to reviewer's comments

* Fixes according to reviewer's comments

* More cleanup

* Move things around - small refactoring

* Fix typo

* Update calculator - add tests

* Fixes according to reviewer's comments
2021-07-15 16:45:59 +02:00
Giordano Ricci
f6b83a4f47
Elasticsearch: Add frozen indices search support (#36018)
* Revert "Revert "Elasticsearch: add frozen indices search support (#27472)" (#27726)"

This reverts commit 4c7131425b.

* Make label width a bit more consistent

* Add documentation for X-Pack & Frozen Indices support in Elasticsearch

* Change UI & docs casing

* create default empty dataframe

* Remove backticks and simplify regex

* small doc improvement
2021-07-15 15:52:02 +02:00
Dimitris Sotirakis
0d08881876
Elasticsearch: Convert Timeseries and Tables to Dataframes (#34710)
* Rebase (broken tests)

* Removed tables - refactored processAggregationDocs func

* Tests cleanup

* Nit - add space in percentile legend titles

* Fix labels naming - use metricAggType map

* Fix bug which appended same fields over and over again

* Replace test with dataframes

* Fix tests

* Add nolint:gocyclo - will need refactoring

* Move frames tags assignment

* Add failing test fo when ES server is booting up

* Revert "Add failing test fo when ES server is booting up"

This reverts commit fd14a1fd5e.

Co-authored-by: Elfo404 <me@giordanoricci.com>
2021-06-18 13:26:19 +03:00
Chris Cowan
f580c9149c
Elasticsearch: Add Top Metrics Aggregation and X-Pack support (#33041)
* Elasticsearch: Add Top Metrics Aggregation

* Adding support for non-timeseries visualizations

* removing console.logs

* restoring loadOptions type

* Honor xpack setting

* Adding test for elastic_response

* adding test for query builder

* Adding support of alerting

* Fixing separator spelling

* Fixing linting issues

* attempting to reduce cyclomatic complexity

* Adding elastic77 Docker block

* Update public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/MetricEditor.test.tsx

Co-authored-by: Giordano Ricci <grdnricci@gmail.com>

* refactoring MetricsEditor tests

* Fixing typo

* Change getFields type & move TopMetrics to a separate component

* Fix SegmentAsync styles in TopMetrics Settings

* Fix field types for TopMetrics

* WIP

* Refactoring client side to support multiple top metrics

* Adding tests and finishing go implimentation

* removing fmt lib from debugging

* fixing tests

* reducing the cyclomatic complexity

* Update public/app/plugins/datasource/elasticsearch/elastic_response.ts

Co-authored-by: Giordano Ricci <grdnricci@gmail.com>

* Update public/app/plugins/datasource/elasticsearch/hooks/useFields.ts

Co-authored-by: Giordano Ricci <grdnricci@gmail.com>

* Checking for possible nil value

* Fixing types

* fix fake-data-gen param

* fix useFields hook

* Removing aggregateBy and size

* Fixing go tests

* Fixing TS tests

* fixing tests

* Fixes

* Remove date from top_metrics fields

* Restore previous formatting

* Update pkg/tsdb/elasticsearch/client/models.go

Co-authored-by: Dimitris Sotirakis <dimitrios.sotirakis@grafana.com>

* Update pkg/tsdb/elasticsearch/client/models.go

Co-authored-by: Dimitris Sotirakis <dimitrios.sotirakis@grafana.com>

* Fix code review comments on processTopMetricValue

* Remove underscore from variable names

* Remove intermediate array definition

* Refactor test to use testify

Co-authored-by: Giordano Ricci <grdnricci@gmail.com>
Co-authored-by: Elfo404 <me@giordanoricci.com>
Co-authored-by: Dimitris Sotirakis <dimitrios.sotirakis@grafana.com>
2021-06-04 11:07:59 +01:00
Ryan McKinley
7627b55ef4
TSDB: add deprecation comments to many tsdb structs (#33281) 2021-04-23 03:03:11 +02:00
Arve Knudsen
b79e61656a
Introduce TSDB service (#31520)
* Introduce TSDB service

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

Co-authored-by: Erik Sundell <erik.sundell87@gmail.com>
Co-authored-by: Will Browne <will.browne@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
2021-03-08 07:02:49 +01:00
Arve Knudsen
a5d9196a53
Chore/fix lint issues (#27704)
* Chore: Fix linting issues

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-09-22 16:22:19 +02:00