mirror of https://github.com/grafana/grafana
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>gio/es-convert-to-dataframes
parent
f683a497eb
commit
f580c9149c
@ -0,0 +1,44 @@ |
||||
# You need to run 'sysctl -w vm.max_map_count=262144' on the host machine |
||||
|
||||
elasticsearch77: |
||||
image: docker.elastic.co/elasticsearch/elasticsearch:7.7.1 |
||||
command: elasticsearch |
||||
environment: |
||||
- "discovery.type=single-node" |
||||
ports: |
||||
- "13200:9200" |
||||
- "13300:9300" |
||||
|
||||
fake-elastic77-data: |
||||
image: grafana/fake-data-gen |
||||
links: |
||||
- elasticsearch77 |
||||
environment: |
||||
FD_SERVER: elasticsearch77 |
||||
FD_DATASOURCE: elasticsearch7 |
||||
FD_PORT: 9200 |
||||
|
||||
filebeat77: |
||||
image: docker.elastic.co/beats/filebeat:7.7.1 |
||||
command: filebeat -e -strict.perms=false |
||||
volumes: |
||||
- ./docker/blocks/elastic77/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro |
||||
- /var/log:/var/log:ro |
||||
- ../data/log:/var/log/grafana:ro |
||||
|
||||
metricbeat77: |
||||
image: docker.elastic.co/beats/metricbeat:7.7.1 |
||||
command: metricbeat -e -strict.perms=false |
||||
user: root |
||||
volumes: |
||||
- ./docker/blocks/elastic77/metricbeat.yml:/usr/share/metricbeat/metricbeat.yml:ro |
||||
- /var/run/docker.sock:/var/run/docker.sock:ro |
||||
|
||||
kibana77: |
||||
image: docker.elastic.co/kibana/kibana:7.7.1 |
||||
ports: |
||||
- "5601:5601" |
||||
links: |
||||
- elasticsearch77 |
||||
environment: |
||||
ELASTICSEARCH_HOSTS: http://elasticsearch77:9200 |
@ -0,0 +1,3 @@ |
||||
script.inline: on |
||||
script.indexed: on |
||||
xpack.license.self_generated.type: basic |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,38 @@ |
||||
metricbeat.config: |
||||
modules: |
||||
path: ${path.config}/modules.d/*.yml |
||||
# Reload module configs as they change: |
||||
reload.enabled: false |
||||
|
||||
metricbeat.autodiscover: |
||||
providers: |
||||
- type: docker |
||||
hints.enabled: true |
||||
|
||||
metricbeat.modules: |
||||
- module: docker |
||||
metricsets: |
||||
- "container" |
||||
- "cpu" |
||||
- "diskio" |
||||
- "healthcheck" |
||||
- "info" |
||||
#- "image" |
||||
- "memory" |
||||
- "network" |
||||
hosts: ["unix:///var/run/docker.sock"] |
||||
period: 10s |
||||
enabled: true |
||||
|
||||
processors: |
||||
- add_cloud_metadata: ~ |
||||
|
||||
output.elasticsearch: |
||||
hosts: ["elasticsearch77:9200"] |
||||
index: "metricbeat-%{+yyyy.MM.dd}" |
||||
|
||||
setup.template.name: "metricbeat" |
||||
setup.template.pattern: "metricbeat-*" |
||||
setup.template.settings: |
||||
index.number_of_shards: 1 |
||||
index.number_of_replicas: 1 |
@ -0,0 +1,69 @@ |
||||
import { AsyncMultiSelect, InlineField, SegmentAsync, Select } from '@grafana/ui'; |
||||
import React, { FunctionComponent } from 'react'; |
||||
import { useDispatch } from '../../../../hooks/useStatelessReducer'; |
||||
import { useFields } from '../../../../hooks/useFields'; |
||||
import { TopMetrics } from '../aggregations'; |
||||
import { changeMetricSetting } from '../state/actions'; |
||||
import { orderOptions } from '../../BucketAggregationsEditor/utils'; |
||||
import { css } from '@emotion/css'; |
||||
import { SelectableValue } from '@grafana/data'; |
||||
|
||||
interface Props { |
||||
metric: TopMetrics; |
||||
} |
||||
|
||||
const toMultiSelectValue = (value: string): SelectableValue<string> => ({ value, label: value }); |
||||
|
||||
export const TopMetricsSettingsEditor: FunctionComponent<Props> = ({ metric }) => { |
||||
const dispatch = useDispatch(); |
||||
const getOrderByOptions = useFields(['number', 'date']); |
||||
const getMetricsOptions = useFields(metric.type); |
||||
|
||||
return ( |
||||
<> |
||||
<InlineField label="Metrics" labelWidth={16}> |
||||
<AsyncMultiSelect |
||||
onChange={(e) => |
||||
dispatch( |
||||
changeMetricSetting( |
||||
metric, |
||||
'metrics', |
||||
e.map((v) => v.value!) |
||||
) |
||||
) |
||||
} |
||||
loadOptions={getMetricsOptions} |
||||
value={metric.settings?.metrics?.map(toMultiSelectValue)} |
||||
closeMenuOnSelect={false} |
||||
defaultOptions |
||||
/> |
||||
</InlineField> |
||||
<InlineField label="Order" labelWidth={16}> |
||||
<Select |
||||
onChange={(e) => dispatch(changeMetricSetting(metric, 'order', e.value))} |
||||
options={orderOptions} |
||||
value={metric.settings?.order} |
||||
/> |
||||
</InlineField> |
||||
<InlineField |
||||
label="Order By" |
||||
labelWidth={16} |
||||
className={css` |
||||
& > div { |
||||
width: 100%; |
||||
} |
||||
`}
|
||||
> |
||||
<SegmentAsync |
||||
className={css` |
||||
margin-right: 0; |
||||
`}
|
||||
loadOptions={getOrderByOptions} |
||||
onChange={(e) => dispatch(changeMetricSetting(metric, 'orderBy', e.value))} |
||||
placeholder="Select Field" |
||||
value={metric.settings?.orderBy} |
||||
/> |
||||
</InlineField> |
||||
</> |
||||
); |
||||
}; |
Loading…
Reference in new issue