fluent-plugin-elasticsearch 4.3.3 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -109,19 +109,9 @@ Current maintainers: @cosmo0920
109
109
  + [chunk_id_key](#chunk_id_key)
110
110
  * [Configuration - Elasticsearch Input](#configuration---elasticsearch-input)
111
111
  * [Configuration - Elasticsearch Filter GenID](#configuration---elasticsearch-filter-genid)
112
+ * [Configuration - Elasticsearch Output Data Stream](#configuration---elasticsearch-output-data-stream)
112
113
  * [Elasticsearch permissions](#elasticsearch-permissions)
113
114
  * [Troubleshooting](#troubleshooting)
114
- + [Cannot send events to elasticsearch](#cannot-send-events-to-elasticsearch)
115
- + [Cannot see detailed failure log](#cannot-see-detailed-failure-log)
116
- + [Cannot connect TLS enabled reverse Proxy](#cannot-connect-tls-enabled-reverse-proxy)
117
- + [Declined logs are resubmitted forever, why?](#declined-logs-are-resubmitted-forever-why)
118
- + [Suggested to install typhoeus gem, why?](#suggested-to-install-typhoeus-gem-why)
119
- + [Stopped to send events on k8s, why?](#stopped-to-send-events-on-k8s-why)
120
- + [Random 400 - Rejected by Elasticsearch is occured, why?](#random-400---rejected-by-elasticsearch-is-occured-why)
121
- + [Fluentd seems to hang if it unable to connect Elasticsearch, why?](#fluentd-seems-to-hang-if-it-unable-to-connect-elasticsearch-why)
122
- + [Enable Index Lifecycle Management](#enable-index-lifecycle-management)
123
- + [How to specify index codec](#how-to-specify-index-codec)
124
- + [Cannot push logs to Elasticsearch with connect_write timeout reached, why?](#cannot-push-logs-to-elasticsearch-with-connect_write-timeout-reached-why)
125
115
  * [Contact](#contact)
126
116
  * [Contributing](#contributing)
127
117
  * [Running tests](#running-tests)
@@ -1422,591 +1412,32 @@ features in the plugin configuration
1422
1412
  The list of privileges along with their description can be found in
1423
1413
  [security privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-privileges.html).
1424
1414
 
1425
- ## Troubleshooting
1426
-
1427
- ### Cannot send events to Elasticsearch
1428
-
1429
- A common cause of failure is that you are trying to connect to an Elasticsearch instance with an incompatible version.
1430
-
1431
- For example, td-agent currently bundles the 6.x series of the [elasticsearch-ruby](https://github.com/elastic/elasticsearch-ruby) library. This means that your Elasticsearch server also needs to be 6.x. You can check the actual version of the client library installed on your system by executing the following command.
1432
-
1433
- ```
1434
- # For td-agent users
1435
- $ /usr/sbin/td-agent-gem list elasticsearch
1436
- # For standalone Fluentd users
1437
- $ fluent-gem list elasticsearch
1438
- ```
1439
- Or, fluent-plugin-elasticsearch v2.11.7 or later, users can inspect version incompatibility with the `validate_client_version` option:
1440
-
1441
- ```
1442
- validate_client_version true
1443
- ```
1444
-
1445
- If you get the following error message, please consider to install compatible elasticsearch client gems:
1446
-
1447
- ```
1448
- Detected ES 5 but you use ES client 6.1.0.
1449
- Please consider to use 5.x series ES client.
1450
- ```
1451
-
1452
- For further details of the version compatibility issue, please read [the official manual](https://github.com/elastic/elasticsearch-ruby#compatibility).
1453
-
1454
- ### Cannot see detailed failure log
1455
-
1456
- A common cause of failure is that you are trying to connect to an Elasticsearch instance with an incompatible ssl protocol version.
1457
-
1458
- For example, `out_elasticsearch` set up ssl_version to TLSv1 due to historical reason.
1459
- Modern Elasticsearch ecosystem requests to communicate with TLS v1.2 or later.
1460
- But, in this case, `out_elasticsearch` conceals transporter part failure log by default.
1461
- If you want to acquire transporter log, please consider to set the following configuration:
1462
-
1463
- ```
1464
- with_transporter_log true
1465
- @log_level debug
1466
- ```
1467
-
1468
- Then, the following log is shown in Fluentd log:
1469
-
1470
- ```
1471
- 2018-10-24 10:00:00 +0900 [error]: #0 [Faraday::ConnectionFailed] SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol (OpenSSL::SSL::SSLError) {:host=>"elasticsearch-host", :port=>80, :scheme=>"https", :user=>"elastic", :password=>"changeme", :protocol=>"https"}
1472
- ```
1473
-
1474
- This indicates that inappropriate TLS protocol version is used.
1475
- If you want to use TLS v1.2, please use `ssl_version` parameter like as:
1476
-
1477
- ```
1478
- ssl_version TLSv1_2
1479
- ```
1480
-
1481
- or, in v4.0.2 or later with Ruby 2.5 or later combination, the following congiuration is also valid:
1482
-
1483
- ```
1484
- ssl_max_version TLSv1_2
1485
- ssl_min_version TLSv1_2
1486
- ```
1487
-
1488
- ### Cannot connect TLS enabled reverse Proxy
1489
-
1490
- A common cause of failure is that you are trying to connect to an Elasticsearch instance behind nginx reverse proxy which uses an incompatible ssl protocol version.
1491
-
1492
- For example, `out_elasticsearch` set up ssl_version to TLSv1 due to historical reason.
1493
- Nowadays, nginx reverse proxy uses TLS v1.2 or later for security reason.
1494
- But, in this case, `out_elasticsearch` conceals transporter part failure log by default.
1495
-
1496
- If you set up nginx reverse proxy with TLS v1.2:
1497
-
1498
- ```
1499
- server {
1500
- listen <your IP address>:9400;
1501
- server_name <ES-Host>;
1502
- ssl on;
1503
- ssl_certificate /etc/ssl/certs/server-bundle.pem;
1504
- ssl_certificate_key /etc/ssl/private/server-key.pem;
1505
- ssl_client_certificate /etc/ssl/certs/ca.pem;
1506
- ssl_verify_client on;
1507
- ssl_verify_depth 2;
1508
-
1509
- # Reference : https://cipherli.st/
1510
- ssl_protocols TLSv1.2;
1511
- ssl_prefer_server_ciphers on;
1512
- ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
1513
- ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
1514
- ssl_session_cache shared:SSL:10m;
1515
- ssl_session_tickets off; # Requires nginx >= 1.5.9
1516
- ssl_stapling on; # Requires nginx >= 1.3.7
1517
- ssl_stapling_verify on; # Requires nginx => 1.3.7
1518
- resolver 127.0.0.1 valid=300s;
1519
- resolver_timeout 5s;
1520
- add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
1521
- add_header X-Frame-Options DENY;
1522
- add_header X-Content-Type-Options nosniff;
1523
-
1524
- client_max_body_size 64M;
1525
- keepalive_timeout 5;
1526
-
1527
- location / {
1528
- proxy_set_header Host $host;
1529
- proxy_set_header X-Real-IP $remote_addr;
1530
- proxy_pass http://localhost:9200;
1531
- }
1532
- }
1533
- ```
1534
-
1535
- Then, nginx reverse proxy starts with TLSv1.2.
1415
+ ## Configuration - Elasticsearch Output Data Stream
1536
1416
 
1537
- Fluentd suddenly dies with the following log:
1538
- ```
1539
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: log writing failed. execution expired
1540
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: /opt/fluentd/embedded/lib/ruby/gems/2.4.0/gems/excon-0.62.0/lib/excon/ssl_socket.rb:10:in `initialize': stack level too deep (SystemStackError)
1541
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: from /opt/fluentd/embedded/lib/ruby/gems/2.4.0/gems/excon-0.62.0/lib/excon/connection.rb:429:in `new'
1542
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: from /opt/fluentd/embedded/lib/ruby/gems/2.4.0/gems/excon-0.62.0/lib/excon/connection.rb:429:in `socket'
1543
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: from /opt/fluentd/embedded/lib/ruby/gems/2.4.0/gems/excon-0.62.0/lib/excon/connection.rb:111:in `request_call'
1544
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: from /opt/fluentd/embedded/lib/ruby/gems/2.4.0/gems/excon-0.62.0/lib/excon/middlewares/mock.rb:48:in `request_call'
1545
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: from /opt/fluentd/embedded/lib/ruby/gems/2.4.0/gems/excon-0.62.0/lib/excon/middlewares/instrumentor.rb:26:in `request_call'
1546
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: from /opt/fluentd/embedded/lib/ruby/gems/2.4.0/gems/excon-0.62.0/lib/excon/middlewares/base.rb:16:in `request_call'
1547
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: from /opt/fluentd/embedded/lib/ruby/gems/2.4.0/gems/excon-0.62.0/lib/excon/middlewares/base.rb:16:in `request_call'
1548
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: from /opt/fluentd/embedded/lib/ruby/gems/2.4.0/gems/excon-0.62.0/lib/excon/middlewares/base.rb:16:in `request_call'
1549
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: ... 9266 levels...
1550
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: from /opt/td-agent/embedded/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
1551
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: from /opt/fluentd/embedded/lib/ruby/gems/2.4.0/gems/fluentd-1.2.5/bin/fluentd:8:in `<top (required)>'
1552
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: from /opt/fluentd/embedded/bin/fluentd:22:in `load'
1553
- Oct 31 9:44:45 <ES-Host> fluentd[6442]: from /opt/fluentd/embedded/bin/fluentd:22:in `<main>'
1554
- Oct 31 9:44:45 <ES-Host> systemd[1]: fluentd.service: Control process exited, code=exited status=1
1555
- ```
1417
+ Since Elasticsearch 7.9, Data Streams was introduced.
1556
1418
 
1557
- If you want to acquire transporter log, please consider to set the following configuration:
1419
+ You can enable this feature by specifying `@type elasticsearch_data_stream`.
1558
1420
 
1559
1421
  ```
1560
- with_transporter_log true
1561
- @log_level debug
1422
+ @type elasticsearch_data_stream
1423
+ data_stream_name test
1562
1424
  ```
1563
1425
 
1564
- Then, the following log is shown in Fluentd log:
1426
+ When `@type elasticsearch_data_stream` is used, ILM default policy is set to the specified data stream.
1427
+ Then, the matching index template is also created automatically.
1565
1428
 
1566
- ```
1567
- 2018-10-31 10:00:57 +0900 [warn]: #7 [Faraday::ConnectionFailed] Attempt 2 connecting to {:host=>"<ES-Host>", :port=>9400, :scheme=>"https", :protocol=>"https"}
1568
- 2018-10-31 10:00:57 +0900 [error]: #7 [Faraday::ConnectionFailed] Connection reset by peer - SSL_connect (Errno::ECONNRESET) {:host=>"<ES-Host>", :port=>9400, :scheme=>"https", :protocol=>"https"}
1569
- ```
1429
+ ### data_stream_name
1570
1430
 
1571
- The above logs indicates that using incompatible SSL/TLS version between fluent-plugin-elasticsearch and nginx, which is reverse proxy, is root cause of this issue.
1431
+ You can specify Elasticsearch data stream name by this parameter.
1432
+ This parameter is mandatory for `elasticsearch_data_stream`.
1572
1433
 
1573
- If you want to use TLS v1.2, please use `ssl_version` parameter like as:
1434
+ There are some limitations about naming rule.
1574
1435
 
1575
- ```
1576
- ssl_version TLSv1_2
1577
- ```
1578
-
1579
- or, in v4.0.2 or later with Ruby 2.5 or later combination, the following congiuration is also valid:
1436
+ In more detail, please refer to the [Path parameters](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-data-stream.html#indices-create-data-stream-api-path-params).
1580
1437
 
1581
- ```
1582
- ssl_max_version TLSv1_2
1583
- ssl_min_version TLSv1_2
1584
- ```
1585
-
1586
- ### Declined logs are resubmitted forever, why?
1587
-
1588
- Sometimes users write Fluentd configuration like this:
1589
-
1590
- ```aconf
1591
- <match **>
1592
- @type elasticsearch
1593
- host localhost
1594
- port 9200
1595
- type_name fluentd
1596
- logstash_format true
1597
- time_key @timestamp
1598
- include_timestamp true
1599
- reconnect_on_error true
1600
- reload_on_failure true
1601
- reload_connections false
1602
- request_timeout 120s
1603
- </match>
1604
- ```
1605
-
1606
- The above configuration does not use [`@label` feature](https://docs.fluentd.org/v1.0/articles/config-file#(5)-group-filter-and-output:-the-%E2%80%9Clabel%E2%80%9D-directive) and use glob(**) pattern.
1607
- It is usually problematic configuration.
1608
-
1609
- In error scenario, error events will be emitted with `@ERROR` label, and `fluent.*` tag.
1610
- The black hole glob pattern resubmits a problematic event into pushing Elasticsearch pipeline.
1611
-
1612
- This situation causes flood of declined log:
1613
-
1614
- ```log
1615
- 2018-11-13 11:16:27 +0000 [warn]: #0 dump an error event: error_class=Fluent::Plugin::ElasticsearchErrorHandler::ElasticsearchError error="400 - Rejected by Elasticsearch" location=nil tag="app.fluentcat" time=2018-11-13 11:16:17.492985640 +0000 record={"message"=>"\xFF\xAD"}
1616
- 2018-11-13 11:16:38 +0000 [warn]: #0 dump an error event: error_class=Fluent::Plugin::ElasticsearchErrorHandler::ElasticsearchError error="400 - Rejected by Elasticsearch" location=nil tag="fluent.warn" time=2018-11-13 11:16:27.978851140 +0000 record={"error"=>"#<Fluent::Plugin::ElasticsearchErrorHandler::ElasticsearchError: 400 - Rejected by Elasticsearch>", "location"=>nil, "tag"=>"app.fluentcat", "time"=>2018-11-13 11:16:17.492985640 +0000, "record"=>{"message"=>"\xFF\xAD"}, "message"=>"dump an error event: error_class=Fluent::Plugin::ElasticsearchErrorHandler::ElasticsearchError error=\"400 - Rejected by Elasticsearch\" location=nil tag=\"app.fluentcat\" time=2018-11-13 11:16:17.492985640 +0000 record={\"message\"=>\"\\xFF\\xAD\"}"}
1617
- ```
1618
-
1619
- Then, user should use more concrete tag route or use `@label`.
1620
- The following sections show two examples how to solve flood of declined log.
1621
- One is using concrete tag routing, the other is using label routing.
1622
-
1623
- #### Using concrete tag routing
1624
-
1625
- The following configuration uses concrete tag route:
1626
-
1627
- ```aconf
1628
- <match out.elasticsearch.**>
1629
- @type elasticsearch
1630
- host localhost
1631
- port 9200
1632
- type_name fluentd
1633
- logstash_format true
1634
- time_key @timestamp
1635
- include_timestamp true
1636
- reconnect_on_error true
1637
- reload_on_failure true
1638
- reload_connections false
1639
- request_timeout 120s
1640
- </match>
1641
- ```
1642
-
1643
- #### Using label feature
1644
-
1645
- The following configuration uses label:
1646
-
1647
- ```aconf
1648
- <source>
1649
- @type forward
1650
- @label @ES
1651
- </source>
1652
- <label @ES>
1653
- <match out.elasticsearch.**>
1654
- @type elasticsearch
1655
- host localhost
1656
- port 9200
1657
- type_name fluentd
1658
- logstash_format true
1659
- time_key @timestamp
1660
- include_timestamp true
1661
- reconnect_on_error true
1662
- reload_on_failure true
1663
- reload_connections false
1664
- request_timeout 120s
1665
- </match>
1666
- </label>
1667
- <label @ERROR>
1668
- <match **>
1669
- @type stdout
1670
- </match>
1671
- </label>
1672
- ```
1673
-
1674
- ### Suggested to install typhoeus gem, why?
1675
-
1676
- fluent-plugin-elasticsearch doesn't depend on typhoeus gem by default.
1677
- If you want to use typhoeus backend, you must install typhoeus gem by your own.
1678
-
1679
- If you use vanilla Fluentd, you can install it by:
1680
-
1681
- ```
1682
- gem install typhoeus
1683
- ```
1684
-
1685
- But, you use td-agent instead of vanilla Fluentd, you have to use `td-agent-gem`:
1686
-
1687
- ```
1688
- td-agent-gem install typhoeus
1689
- ```
1690
-
1691
- In more detail, please refer to [the official plugin management document](https://docs.fluentd.org/v1.0/articles/plugin-management).
1692
-
1693
- ### Stopped to send events on k8s, why?
1694
-
1695
- fluent-plugin-elasticsearch reloads connection after 10000 requests. (Not correspond to events counts because ES plugin uses bulk API.)
1696
-
1697
- This functionality which is originated from elasticsearch-ruby gem is enabled by default.
1698
-
1699
- Sometimes this reloading functionality bothers users to send events with ES plugin.
1700
-
1701
- On k8s platform, users sometimes shall specify the following settings:
1702
-
1703
- ```aconf
1704
- reload_connections false
1705
- reconnect_on_error true
1706
- reload_on_failure true
1707
- ```
1708
-
1709
- If you use [fluentd-kubernetes-daemonset](https://github.com/fluent/fluentd-kubernetes-daemonset), you can specify them with environment variables:
1710
-
1711
- * `FLUENT_ELASTICSEARCH_RELOAD_CONNECTIONS` as `false`
1712
- * `FLUENT_ELASTICSEARCH_RECONNECT_ON_ERROR` as `true`
1713
- * `FLUENT_ELASTICSEARCH_RELOAD_ON_FAILURE` as `true`
1714
-
1715
- This issue had been reported at [#525](https://github.com/uken/fluent-plugin-elasticsearch/issues/525).
1716
-
1717
- ### Random 400 - Rejected by Elasticsearch is occured, why?
1718
-
1719
- Index templates installed Elasticsearch sometimes generates 400 - Rejected by Elasticsearch errors.
1720
- For example, kubernetes audit log has structure:
1721
-
1722
- ```json
1723
- "responseObject":{
1724
- "kind":"SubjectAccessReview",
1725
- "apiVersion":"authorization.k8s.io/v1beta1",
1726
- "metadata":{
1727
- "creationTimestamp":null
1728
- },
1729
- "spec":{
1730
- "nonResourceAttributes":{
1731
- "path":"/",
1732
- "verb":"get"
1733
- },
1734
- "user":"system:anonymous",
1735
- "group":[
1736
- "system:unauthenticated"
1737
- ]
1738
- },
1739
- "status":{
1740
- "allowed":true,
1741
- "reason":"RBAC: allowed by ClusterRoleBinding \"cluster-system-anonymous\" of ClusterRole \"cluster-admin\" to User \"system:anonymous\""
1742
- }
1743
- },
1744
- ```
1745
-
1746
- The last element `status` sometimes becomes `"status":"Success"`.
1747
- This element type glich causes status 400 error.
1748
-
1749
- There are some solutions for fixing this:
1750
-
1751
- #### Solution 1
1752
-
1753
- For a key which causes element type glich case.
1754
-
1755
- Using dymanic mapping with the following template:
1756
-
1757
- ```json
1758
- {
1759
- "template": "YOURINDEXNAME-*",
1760
- "mappings": {
1761
- "fluentd": {
1762
- "dynamic_templates": [
1763
- {
1764
- "default_no_index": {
1765
- "path_match": "^.*$",
1766
- "path_unmatch": "^(@timestamp|auditID|level|stage|requestURI|sourceIPs|metadata|objectRef|user|verb)(\\..+)?$",
1767
- "match_pattern": "regex",
1768
- "mapping": {
1769
- "index": false,
1770
- "enabled": false
1771
- }
1772
- }
1773
- }
1774
- ]
1775
- }
1776
- }
1777
- }
1778
- ```
1779
-
1780
- Note that `YOURINDEXNAME` should be replaced with your using index prefix.
1781
-
1782
- #### Solution 2
1783
-
1784
- For unstable `responseObject` and `requestObject` key existence case.
1785
-
1786
- ```aconf
1787
- <filter YOURROUTETAG>
1788
- @id kube_api_audit_normalize
1789
- @type record_transformer
1790
- auto_typecast false
1791
- enable_ruby true
1792
- <record>
1793
- host "#{ENV['K8S_NODE_NAME']}"
1794
- responseObject ${record["responseObject"].nil? ? "none": record["responseObject"].to_json}
1795
- requestObject ${record["requestObject"].nil? ? "none": record["requestObject"].to_json}
1796
- origin kubernetes-api-audit
1797
- </record>
1798
- </filter>
1799
- ```
1800
-
1801
- Normalize `responseObject` and `requestObject` key with record_transformer and other similiar plugins is needed.
1802
-
1803
- ### Fluentd seems to hang if it unable to connect Elasticsearch, why?
1804
-
1805
- On `#configure` phase, ES plugin should wait until ES instance communication is succeeded.
1806
- And ES plugin blocks to launch Fluentd by default.
1807
- Because Fluentd requests to set up configuration correctly on `#configure` phase.
1808
-
1809
- After `#configure` phase, it runs very fast and send events heavily in some heavily using case.
1810
-
1811
- In this scenario, we need to set up configuration correctly until `#configure` phase.
1812
- So, we provide default parameter is too conservative to use advanced users.
1813
-
1814
- To remove too pessimistic behavior, you can use the following configuration:
1815
-
1816
- ```aconf
1817
- <match **>
1818
- @type elasticsearch
1819
- # Some advanced users know their using ES version.
1820
- # We can disable startup ES version checking.
1821
- verify_es_version_at_startup false
1822
- # If you know that your using ES major version is 7, you can set as 7 here.
1823
- default_elasticsearch_version 7
1824
- # If using very stable ES cluster, you can reduce retry operation counts. (minmum is 1)
1825
- max_retry_get_es_version 1
1826
- # If using very stable ES cluster, you can reduce retry operation counts. (minmum is 1)
1827
- max_retry_putting_template 1
1828
- # ... and some ES plugin configuration
1829
- </match>
1830
- ```
1831
-
1832
- ### Enable Index Lifecycle Management
1833
-
1834
- Index lifecycle management is template based index management feature.
1835
-
1836
- Main ILM feature parameters are:
1837
-
1838
- * `index_name` (when logstash_format as false)
1839
- * `logstash_prefix` (when logstash_format as true)
1840
- * `enable_ilm`
1841
- * `ilm_policy_id`
1842
- * `ilm_policy`
1843
-
1844
- * Advanced usage parameters
1845
- * `application_name`
1846
- * `index_separator`
1847
-
1848
- They are not all mandatory parameters but they are used for ILM feature in effect.
1849
-
1850
- ILM target index alias is created with `index_name` or an index which is calculated from `logstash_prefix`.
1851
-
1852
- From Elasticsearch plugin v4.0.0, ILM target index will be calculated from `index_name` (normal mode) or `logstash_prefix` (using with `logstash_format`as true).
1853
-
1854
- **NOTE:** Before Elasticsearch plugin v4.1.0, using `deflector_alias` parameter when ILM is enabled is permitted and handled, but, in the later releases such that 4.1.1 or later, it cannot use with when ILM is enabled.
1855
-
1856
- And also, ILM feature users should specify their Elasticsearch template for ILM enabled indices.
1857
- Because ILM settings are injected into their Elasticsearch templates.
1858
-
1859
- `application_name` and `index_separator` also affect alias index names.
1860
-
1861
- But this parameter is prepared for advanced usage.
1862
-
1863
- It usually should be used with default value which is `default`.
1864
-
1865
- Then, ILM parameters are used in alias index like as:
1866
-
1867
- ##### Simple `index_name` case:
1868
-
1869
- `<index_name><index_separator><application_name>-000001`.
1870
-
1871
- ##### `logstash_format` as `true` case:
1872
-
1873
- `<logstash_prefix><logstash_prefix_separator><application_name><logstash_prefix_separator><logstash_dateformat>-000001`.
1874
-
1875
- #### Example ILM settings
1876
-
1877
- ```aconf
1878
- index_name fluentd-${tag}
1879
- application_name ${tag}
1880
- index_date_pattern "now/d"
1881
- enable_ilm true
1882
- # Policy configurations
1883
- ilm_policy_id fluentd-policy
1884
- # ilm_policy {} # Use default policy
1885
- template_name your-fluentd-template
1886
- template_file /path/to/fluentd-template.json
1887
- # customize_template {"<<index_prefix>>": "fluentd"}
1888
- ```
1889
-
1890
- Note: This plugin only creates rollover-enabled indices, which are aliases pointing to them and index templates, and creates an ILM policy if enabled.
1891
-
1892
- #### Create ILM indices in each day
1893
-
1894
- If you want to create new index in each day, you should use `logstash_format` style configuration:
1895
-
1896
- ```aconf
1897
- logstash_prefix fluentd
1898
- application_name default
1899
- index_date_pattern "now/d"
1900
- enable_ilm true
1901
- # Policy configurations
1902
- ilm_policy_id fluentd-policy
1903
- # ilm_policy {} # Use default policy
1904
- template_name your-fluentd-template
1905
- template_file /path/to/fluentd-template.json
1906
- ```
1907
-
1908
- Note that if you create a new set of indexes every day, the elasticsearch ILM policy system will treat each day separately and will always
1909
- maintain a separate active write index for each day.
1910
-
1911
- If you have a rollover based on max_age, it will continue to roll the indexes for prior dates even if no new documents are indexed. If you want
1912
- to delete indexes after a period of time, the ILM policy will never delete the current write index regardless of its age, so you would need a separate
1913
- system, such as curator, to actually delete the old indexes.
1914
-
1915
- For this reason, if you put the date into the index names with ILM you should only rollover based on size or number of documents and may need to use
1916
- curator to actually delete old indexes.
1917
-
1918
- #### Fixed ILM indices
1919
-
1920
- Also, users can use fixed ILM indices configuration.
1921
- If `index_date_pattern` is set as `""`(empty string), Elasticsearch plugin won't attach date pattern in ILM indices:
1922
-
1923
- ```aconf
1924
- index_name fluentd
1925
- application_name default
1926
- index_date_pattern ""
1927
- enable_ilm true
1928
- # Policy configurations
1929
- ilm_policy_id fluentd-policy
1930
- # ilm_policy {} # Use default policy
1931
- template_name your-fluentd-template
1932
- template_file /path/to/fluentd-template.json
1933
- ```
1934
-
1935
- ### How to specify index codec
1936
-
1937
- Elasticsearch can handle compression methods for stored data such as LZ4 and best_compression.
1938
- fluent-plugin-elasticsearch doesn't provide API which specifies compression method.
1939
-
1940
- Users can specify stored data compression method with template:
1941
-
1942
- Create `compression.json` as follows:
1943
-
1944
- ```json
1945
- {
1946
- "order": 100,
1947
- "index_patterns": [
1948
- "YOUR-INDEX-PATTERN"
1949
- ],
1950
- "settings": {
1951
- "index": {
1952
- "codec": "best_compression"
1953
- }
1954
- }
1955
- }
1956
- ```
1957
-
1958
- Then, specify the above template in your configuration:
1959
-
1960
- ```aconf
1961
- template_name best_compression_tmpl
1962
- template_file compression.json
1963
- ```
1964
-
1965
- Elasticsearch will store data with `best_compression`:
1966
-
1967
- ```
1968
- % curl -XGET 'http://localhost:9200/logstash-2019.12.06/_settings?pretty'
1969
- ```
1970
-
1971
- ```json
1972
- {
1973
- "logstash-2019.12.06" : {
1974
- "settings" : {
1975
- "index" : {
1976
- "codec" : "best_compression",
1977
- "number_of_shards" : "1",
1978
- "provided_name" : "logstash-2019.12.06",
1979
- "creation_date" : "1575622843800",
1980
- "number_of_replicas" : "1",
1981
- "uuid" : "THE_AWESOMEUUID",
1982
- "version" : {
1983
- "created" : "7040100"
1984
- }
1985
- }
1986
- }
1987
- }
1988
- }
1989
- ```
1990
-
1991
- ### Cannot push logs to Elasticsearch with connect_write timeout reached, why?
1992
-
1993
- It seems that Elasticsearch cluster is exhausted.
1994
-
1995
- Usually, Fluentd complains like the following log:
1996
-
1997
- ```log
1998
- 2019-12-29 00:23:33 +0000 [warn]: buffer flush took longer time than slow_flush_log_threshold: elapsed_time=27.283766102716327 slow_flush_log_threshold=15.0 plugin_id="object:aaaffaaaaaff"
1999
- 2019-12-29 00:23:33 +0000 [warn]: buffer flush took longer time than slow_flush_log_threshold: elapsed_time=26.161768959928304 slow_flush_log_threshold=15.0 plugin_id="object:aaaffaaaaaff"
2000
- 2019-12-29 00:23:33 +0000 [warn]: buffer flush took longer time than slow_flush_log_threshold: elapsed_time=28.713624476008117 slow_flush_log_threshold=15.0 plugin_id="object:aaaffaaaaaff"
2001
- 2019-12-29 01:39:18 +0000 [warn]: Could not push logs to Elasticsearch, resetting connection and trying again. connect_write timeout reached
2002
- 2019-12-29 01:39:18 +0000 [warn]: Could not push logs to Elasticsearch, resetting connection and trying again. connect_write timeout reached
2003
- ```
2004
-
2005
- This warnings is usually caused by exhaused Elasticsearch cluster due to resource shortage.
2006
-
2007
- If CPU usage is spiked and Elasticsearch cluster is eating up CPU resource, this issue is caused by CPU resource shortage.
1438
+ ## Troubleshooting
2008
1439
 
2009
- Check your Elasticsearch cluster health status and resource usage.
1440
+ See [Troubleshooting document](README.Troubleshooting.md)
2010
1441
 
2011
1442
  ## Contact
2012
1443