Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding elasticsearch/ccr metricset #8335

Merged
merged 9 commits into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ https://github.com/elastic/beats/compare/v6.4.0...master[Check the HEAD diff]
- Add support to renamed fields planned for redis 5.0. {pull}8167[8167]
- Allow TCP helper to support delimiters and graphite module to accept multiple metrics in a single payload. {pull}8278[8278]
- Added 'died' PID state to process_system metricset on system module{pull}8275[8275]
- Added `ccr` metricset to Elasticsearch module. {pull}8335[8335]

*Packetbeat*

Expand Down
79 changes: 79 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3459,6 +3459,85 @@ type: keyword
Elasticsearch state id.


--

[float]
== ccr fields

Cross-cluster replication stats




*`elasticsearch.ccr.leader.index`*::
+
--
type: keyword

Name of leader index


--

*`elasticsearch.ccr.leader.max_seq_no`*::
+
--
type: long

Maximum sequence number of operation on the leader shard


--


*`elasticsearch.ccr.follower.index`*::
+
--
type: keyword

Name of follower index


--

*`elasticsearch.ccr.follower.shard.number`*::
+
--
type: long

Number of the shard within the index


--

*`elasticsearch.ccr.follower.operations_indexed`*::
+
--
type: long

Number of operations indexed (replicated) into the follower shard from the leader shard


--

*`elasticsearch.ccr.follower.time_since_last_fetch.ms`*::
+
--
type: long

Time, in ms, since the follower last fetched from the leader


--

*`elasticsearch.ccr.follower.global_checkpoint`*::
+
--
type: long

Global checkpoint value on follower shard


--

[float]
Expand Down
4 changes: 4 additions & 0 deletions metricbeat/docs/modules/elasticsearch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ This module supports TLS connection when using `ssl` config field, as described

The following metricsets are available:

* <<metricbeat-metricset-elasticsearch-ccr,ccr>>

* <<metricbeat-metricset-elasticsearch-cluster_stats,cluster_stats>>

* <<metricbeat-metricset-elasticsearch-index,index>>
Expand All @@ -68,6 +70,8 @@ The following metricsets are available:

* <<metricbeat-metricset-elasticsearch-shard,shard>>

include::elasticsearch/ccr.asciidoc[]

include::elasticsearch/cluster_stats.asciidoc[]

include::elasticsearch/index.asciidoc[]
Expand Down
23 changes: 23 additions & 0 deletions metricbeat/docs/modules/elasticsearch/ccr.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
////
This file is generated! See scripts/docs_collector.py
////

[[metricbeat-metricset-elasticsearch-ccr]]
=== Elasticsearch ccr metricset

beta[]

include::../../../module/elasticsearch/ccr/_meta/docs.asciidoc[]


==== Fields

For a description of each field in the metricset, see the
<<exported-fields-elasticsearch,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/elasticsearch/ccr/_meta/data.json[]
----
3 changes: 2 additions & 1 deletion metricbeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ This file is generated! See scripts/docs_collector.py
|<<metricbeat-module-dropwizard,Dropwizard>> beta[] |image:./images/icon-no.png[No prebuilt dashboards] |
.1+| .1+| |<<metricbeat-metricset-dropwizard-collector,collector>> beta[]
|<<metricbeat-module-elasticsearch,Elasticsearch>> beta[] |image:./images/icon-no.png[No prebuilt dashboards] |
.9+| .9+| |<<metricbeat-metricset-elasticsearch-cluster_stats,cluster_stats>> beta[]
.10+| .10+| |<<metricbeat-metricset-elasticsearch-ccr,ccr>> beta[]
|<<metricbeat-metricset-elasticsearch-cluster_stats,cluster_stats>> beta[]
|<<metricbeat-metricset-elasticsearch-index,index>> beta[]
|<<metricbeat-metricset-elasticsearch-index_recovery,index_recovery>> beta[]
|<<metricbeat-metricset-elasticsearch-index_summary,index_summary>> beta[]
Expand Down
16 changes: 16 additions & 0 deletions metricbeat/helper/elastic/elastic.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"strings"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/metricbeat/mb"
)

Expand Down Expand Up @@ -92,3 +93,18 @@ func ReportErrorForMissingField(field string, product Product, r mb.ReporterV2)
func MakeErrorForMissingField(field string, product Product) error {
return fmt.Errorf("Could not find field '%v' in %v stats API response", field, strings.Title(product.String()))
}

// IsFeatureAvailable returns whether a feature is available in the current product version
func IsFeatureAvailable(currentProductVersion, featureAvailableInProductVersion string) (bool, error) {
currentVersion, err := common.NewVersion(currentProductVersion)
if err != nil {
return false, err
}

wantVersion, err := common.NewVersion(featureAvailableInProductVersion)
if err != nil {
return false, err
}

return !currentVersion.LessThan(wantVersion), nil
}
1 change: 1 addition & 0 deletions metricbeat/include/list.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions metricbeat/module/elasticsearch/ccr/_meta/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"@timestamp": "2017-10-12T08:05:34.853Z",
"beat": {
"hostname": "host.example.com",
"name": "host.example.com"
},
"elasticsearch": {
"ccr": {
"follower": {
"global_checkpoint": 1,
"index": "my_follower",
"operations_indexed": 2,
"shard": {
"number": 0
},
"time_since_last_fetch": {
"ms": 4926
}
},
"leader": {
"index": "my_leader",
"max_seq_no": 1
}
},
"cluster": {
"id": "KSGkOjOuSg6whAgtpPyhQw",
"name": "elasticsearch"
}
},
"metricset": {
"host": "127.0.0.1:9200",
"module": "elasticsearch",
"name": "ccr",
"rtt": 115
},
"service": {
"name": "elasticsearch"
}
}
3 changes: 3 additions & 0 deletions metricbeat/module/elasticsearch/ccr/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is the `ccr` metricset of the Elasticsearch module. It interrogates the
Cross Cluster Replication Stats API endpoint to fetch information about shards
in the Elasticsearch cluster that are participating in cross-cluster replication.
40 changes: 40 additions & 0 deletions metricbeat/module/elasticsearch/ccr/_meta/fields.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
- name: ccr
type: group
description: >
Cross-cluster replication stats
release: beta
fields:
- name: leader
type: group
fields:
- name: index
type: keyword
description: >
Name of leader index
- name: max_seq_no
type: long
description: >
Maximum sequence number of operation on the leader shard
- name: follower
type: group
fields:
- name: index
type: keyword
description: >
Name of follower index
- name: shard.number
type: long
description: >
Number of the shard within the index
- name: operations_indexed
type: long
description: >
Number of operations indexed (replicated) into the follower shard from the leader shard
- name: time_since_last_fetch.ms
type: long
description: >
Time, in ms, since the follower last fetched from the leader
- name: global_checkpoint
type: long
description: >
Global checkpoint value on follower shard
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"my_follower": [
{
"leader_index": "my_leader",
"follower_index": "my_follower",
"shard_id": 0,
"leader_global_checkpoint": 1,
"leader_max_seq_no": 1,
"follower_global_checkpoint": 1,
"follower_max_seq_no": 1,
"last_requested_seq_no": 1,
"number_of_concurrent_reads": 1,
"number_of_concurrent_writes": 0,
"number_of_queued_writes": 0,
"mapping_version": 2,
"total_fetch_time_millis": 21,
"number_of_successful_fetches": 142,
"number_of_failed_fetches": 6743,
"operations_received": 2,
"total_transferred_bytes": 166,
"total_index_time_millis": 48,
"number_of_successful_bulk_operations": 2,
"number_of_failed_bulk_operations": 0,
"number_of_operations_indexed": 2,
"fetch_exceptions": [
{
"from_seq_no": 2,
"retries": 6743,
"exception": {
"type": "exception",
"reason": "NoShardAvailableActionException[No shard available for [Request{fromSeqNo=2, maxOperationCount=1024, shardId=[leader][0], expectedHistoryUUID=ki9Do9c-QQKVydB-6Txkdg, maxOperationSizeInBytes=9223372036854775807}]]; nested: RemoteTransportException[[d0XH9XU][127.0.0.1:9300][indices:data/read/xpack/ccr/shard_changes[s]]]; nested: IndexNotFoundException[no such index];",
"caused_by": {
"type": "no_shard_available_action_exception",
"reason": "No shard available for [Request{fromSeqNo=2, maxOperationCount=1024, shardId=[leader][0], expectedHistoryUUID=ki9Do9c-QQKVydB-6Txkdg, maxOperationSizeInBytes=9223372036854775807}]",
"caused_by": {
"type": "index_not_found_exception",
"reason": "no such index",
"index_uuid": "RH8_j_w0Q0GGmpY0HMVQ_A",
"index": "my_leader"
}
}
}
}
],
"time_since_last_fetch_millis": 470
},
{
"leader_index": "my_leader",
"follower_index": "my_follower",
"shard_id": 1,
"leader_global_checkpoint": -1,
"leader_max_seq_no": -1,
"follower_global_checkpoint": -1,
"follower_max_seq_no": -1,
"last_requested_seq_no": -1,
"number_of_concurrent_reads": 0,
"number_of_concurrent_writes": 0,
"number_of_queued_writes": 0,
"mapping_version": 2,
"total_fetch_time_millis": 0,
"number_of_successful_fetches": 336,
"number_of_failed_fetches": 0,
"operations_received": 0,
"total_transferred_bytes": 0,
"total_index_time_millis": 0,
"number_of_successful_bulk_operations": 0,
"number_of_failed_bulk_operations": 0,
"number_of_operations_indexed": 0,
"fetch_exceptions": [],
"time_since_last_fetch_millis": 4323
},
{
"leader_index": "my_leader",
"follower_index": "my_follower",
"shard_id": 2,
"leader_global_checkpoint": 1,
"leader_max_seq_no": 1,
"follower_global_checkpoint": 1,
"follower_max_seq_no": 1,
"last_requested_seq_no": 1,
"number_of_concurrent_reads": 0,
"number_of_concurrent_writes": 0,
"number_of_queued_writes": 0,
"mapping_version": 2,
"total_fetch_time_millis": 0,
"number_of_successful_fetches": 372,
"number_of_failed_fetches": 0,
"operations_received": 2,
"total_transferred_bytes": 166,
"total_index_time_millis": 32,
"number_of_successful_bulk_operations": 2,
"number_of_failed_bulk_operations": 0,
"number_of_operations_indexed": 2,
"fetch_exceptions": [],
"time_since_last_fetch_millis": 4323
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading