'Elastic/Beats'에 해당되는 글 13건

  1. 2022.10.25 [Beats] Filebeat Output.logstash 전송 방식.
  2. 2022.08.12 [Filebeats] filebeats input filestream 에서 id 설정의 중요성
  3. 2021.10.07 [Filebeat] ignore_older 와 tail_files 관련.
  4. 2021.02.15 [Metricbeat] Module enable/disable.
  5. 2021.01.20 [Filebeat] registry 파일 내 offset 초기화.
  6. 2020.06.03 [Filebeat] ilm 조심 하자.
  7. 2020.06.03 [Filebeat] template 설정 setup.template.append_fields
  8. 2020.05.25 [Filebeat] setup.ilm & setup.template 잘 쓰려면.
  9. 2020.05.11 [Beats] Filebeat 내 JSON 처리.
  10. 2020.04.01 [Beats] Metricbeat Docker Compose 기본 구성 하기

[Beats] Filebeat Output.logstash 전송 방식.

Elastic/Beats 2022. 10. 25. 15:19

 

Filebeats output.logstash 는 기본 async 로 전송 합니다.

공홈 문서)
https://www.elastic.co/guide/en/beats/filebeat/current/logstash-output.html#_pipelining

pipelining

Configures the number of batches to be sent asynchronously to Logstash while waiting for ACK from Logstash.
Output only becomes blocking once number of pipelining batches have been written. 
Pipelining is disabled if a value of 0 is configured.
The default value is 2.



소스코드)
https://github.com/elastic/beats/blob/main/libbeat/outputs/logstash/logstash.go

if config.Pipelining > 0 {
  client, err = newAsyncClient(beat, conn, observer, config)
} else {
  client, err = newSyncClient(beat, conn, observer, config)
}
 

Configure the Logstash output | Filebeat Reference [8.4] | Elastic

If ILM is not being used, set index to %{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd} instead so Logstash creates an index per day, based on the @timestamp value of the events coming from Beats.

www.elastic.co

 

내용과 코드를 보시면 쉽게 이해가 됩니다.

pipelining 설정은 기본 2 이고 이 값이 0 보다 크면 async 로 전송 하게 됩니다.

참고하세요.

 

더불어ㅏ서 pipelining 값은 core 크기와 동일하게 맞춰서 사용 하시면 성능적 효과를 얻을 수 있습니다.
(정답은 아니고 장비에 대한 용도와 올라가는 어플리케이션에 따라 다를 수 있으니 성능 테스트는 꼭 해보시기 바랍니다.)

:

[Filebeats] filebeats input filestream 에서 id 설정의 중요성

Elastic/Beats 2022. 8. 12. 18:20

filebeats input filesstream 에서 id 설정을 하고 사용 하시길 권장 합니다.

 

코드를 한번 보실 분들은 아래 파일 열어 보시면 됩니다.

filebeat/input/filestream/
  ㄴ filestream.go
  ㄴ input.go

filebeat input 에서는 inode marker 를 이용해서 file offset 에 대한 처리 정보를 기록 합니다.
이를 통해서 데이터를 처리 하게 되는데 여러개의 filestream 을 등록 하게 되면 같은 파일에 대해서 데이터를 중복으로 처리 하거나 우선순위에 따라 먼저 선점한 filestream 이와 다른 filestream 에서 처리가 안되는 경우가 발생 할 수 있습니다.
이를 해결 하기 위해서는 사전에 등록된 file 의 inode marker 를 리셋 하거나 filestream 설정에서 id 지정을 통해서 해결 할 수 있습니다.

 

참고문서)
https://www.elastic.co/guide/en/beats/filebeat/8.3/filebeat-input-filestream.html
https://www.elastic.co/guide/en/beats/filebeat/8.3/filebeat-input-filestream.html#filestream-input-id

 

Each filestream input must have a unique ID. Omitting or changing the filestream ID may cause data duplication. Without a unique ID, filestream is unable to correctly track the state of files.

Changing input ID may cause data duplication becauin the state of the files will be lost and they will be read from the beginning again.

id 값은 유니크 해야 하고 변경 시 데이터가 중복 발생 할 수 있다는 내용입니다.
실제 설정에서 id 설정을 하지 않더라도 실행에는 문제가 되지 않습니다.

:

[Filebeat] ignore_older 와 tail_files 관련.

Elastic/Beats 2021. 10. 7. 19:08

이 두 설정은 같이 고려 하는게 좋습니다.

각 설정은 아래 공홈 문서 참고 하시면 됩니다.

 

https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-log.html#filebeat-input-log-ignore-older

https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-log.html#_tail_files_3

 

[Case 1] filebeat 재시작 시 데이터 유실 없이 사용하기 위한 설정

filebeat.inputs:
- type: log
...중략...
  ignore_older: 0
  tail_files: false
...중략...

 

[Case 2] filebeat 빠른 재시작 시 사용하기 위한 설정

filebeat.inputs:
- type: log
...중략...
  ignore_older: 10m
  tail_files: true
...중략...

가볍게 설정에 대해서 알아보면,

- ignore_older 는 파일의 시간을 가지고 설정된 시간이 지난 파일은 무시 하게 됩니다.

- tail_files 는 파일의 처음 부터 읽을 건지 마지막 부터 읽을 건지 설정을 하게 됩니다.

 

:

[Metricbeat] Module enable/disable.

Elastic/Beats 2021. 2. 15. 10:05

[Enable]
$ ./metricbeat modules enable apache mysql

 

[Disable]
$ ./metricbeat modules disable apache mysql

:

[Filebeat] registry 파일 내 offset 초기화.

Elastic/Beats 2021. 1. 20. 15:14

filebeat 의 registry 관련 설정 정보는 아래 공식 문서를 참고하세요.

www.elastic.co/guide/en/beats/filebeat/current/configuration-general-options.html

 

문서 설명에도 있지만, 

 

- 기본 경로는 아래와 같습니다.

The default is ${path.data}/registry

 

Registry 의 구조체를 확인해 보면 아래와 같은데요.

type Registry struct {
	Path          string        `config:"path"`
	Permissions   os.FileMode   `config:"file_permissions"`
	FlushTimeout  time.Duration `config:"flush"`
	CleanInterval time.Duration `config:"cleanup_interval"`
	MigrateFile   string        `config:"migrate_file"`
}

설정에서 path 를 잡아 주지 않으면, 코드 상으로는  "filebeat.py"

default_registry_path = 'registry/filebeat'

위 경로 아래 meta.json 과 log.json 두 개의 파일이 생기고 파일들에 대한 offset 관리가 이루어 집니다.

 

Logstash input file 의 sincedb 와 같이 offset  정보를 reset 하기 위해서는 

- log.json 에서 offset 설정을 다시 해주거나

- 걍 registry 삭제 하고 재 시작 하시면 됩니다.

 

tail_files 설정도 있고 해당 log file 삭제를 하는 것도 있고, 용도와 목적에 맞게 시도해 보시면 될 것 같습니다.

 

:

[Filebeat] ilm 조심 하자.

Elastic/Beats 2020. 6. 3. 14:19

참고 문서)

https://www.elastic.co/guide/en/beats/filebeat/current/ilm.html

 

setup.ilm.check_exists

When set to false, disables the check for an existing lifecycle policy.

The default is true.

You need to disable this check if the Filebeat user connecting to a secured cluster doesn’t have the read_ilm privilege.

If you set this option to false, set setup.ilm.overwrite: true so the lifecycle policy can be installed.

 

setup.ilm.overwrite

When set to true, the lifecycle policy is overwritten at startup. The default is false.

 

이 설정은 template  설정과 output.elasticsearch.index 랑도 연관이 됩니다.

아주 삽질을 하게 만드는 설정이 될 수도 있습니다.

단, 알고 쓰면 삽질 안하고 모르고 쓰면 삽질 할 수도 있습니다.

 

늘 그렇지만, Elastic 사는 그냥 모르면 기본 설정만 사용하세요. :)

:

[Filebeat] template 설정 setup.template.append_fields

Elastic/Beats 2020. 6. 3. 14:15

참고 문서)

https://www.elastic.co/guide/en/beats/filebeat/current/configuration-template.html

 

설정 중에 필요한 내용이 있어서 기록해 봅니다.

 

setup.template.append_fields

 

A list of fields to be added to the template and Kibana index pattern.

This setting adds new fields. It does not overwrite or change existing fields.

This setting is useful when your data contains fields that Filebeat doesn’t know about in advance.

If append_fields is specified along with overwrite: true,

Filebeat overwrites the existing template and applies the new template when creating new indices.

Existing indices are not affected.

If you’re running multiple instances of Filebeat with different append_fields settings,

the last one writing the template takes precedence.

Any changes to this setting also affect the Kibana index pattern.

 

Example config:

setup.template.overwrite: true

setup.template.append_fields:

  - name: test.name

     type: keyword

  - name: test.hostname

     type: long

 

이 설정으로 dynamic mapping 이나 template 관련 번거로움을 간단하게 해결 할 수 있습니다.

저는 몇 개 field 에 대해서 date 로 설정을 해야 해서 이 설정을 사용했습니다.

 

:

[Filebeat] setup.ilm & setup.template 잘 쓰려면.

Elastic/Beats 2020. 5. 25. 17:09

가끔 설정은 yml 에 잘 했는데 안될 때가 있습니다.

이게 어디에서 뭘로 했느냐에 따라 다른데요.

 

보통 beats 를 이용할 경우 자동으로 alias 생성 및 설정이 됩니다.

이 경우 elasticsearch 에서 동일하게 사용 하기 위한 ilm 과 template 설정을 하게 되면 동작이 잘 안되는 경우가 있는데요.

 

큰 차이는 is_write_index 설정 때문 입니다.

뭐 이것도 경우에 따라 다르게 나올 수 있지만 일반적이라면 저 설정 때문이다 생각 하시면 됩니다.

 

beats 에서는 libbeat 에서 자동으로 설정을 해줍니다.

 

// CreateAlias sends request to Elasticsearch for creating alias.
func (h *ESClientHandler) CreateAlias(alias Alias) error {
	// Escaping because of date pattern
	// This always assume it's a date pattern by sourrounding it by <...>
	firstIndex := fmt.Sprintf("<%s-%s>", alias.Name, alias.Pattern)
	firstIndex = url.PathEscape(firstIndex)

	body := common.MapStr{
		"aliases": common.MapStr{
			alias.Name: common.MapStr{
				"is_write_index": true,
			},
		},
	}

	// Note: actual aliases are accessible via the index
	status, res, err := h.client.Request("PUT", "/"+firstIndex, "", nil, body)
	if status == 400 {
		// HasAlias fails if there is an index with the same name, that is
		// what we want to check here.
		_, err := h.HasAlias(alias.Name)
		if err != nil {
			return err
		}
		return errOf(ErrAliasAlreadyExists)
	} else if err != nil {
		return wrapErrf(err, ErrAliasCreateFailed, "failed to create alias: %s", res)
	}

	return nil
}

하지만, elasticsearch 에서 수동으로 설정을 한다고 하면 꼭 "is_write_index:true" 설정을 해주셔야 alias 생성 및 등록이 잘 된다는거 알고 넘어 가자고요.

 

:

[Beats] Filebeat 내 JSON 처리.

Elastic/Beats 2020. 5. 11. 14:18

1. input type log 에서 처리 하는 방법과

2. processor 에서 decode_json_fields 로 처리 하는 방법이 있습니다.

 

1번은 그냥 전체 로그에 대해서 처리

2번은 특정 필드의 메시지에 대해서 처리

 

자세한건 문서를 참고해 주세요.

 

[Reference]

https://www.elastic.co/guide/en/beats/filebeat/7.6/filebeat-input-log.html

https://www.elastic.co/guide/en/beats/filebeat/7.6/decode-json-fields.html

 

:

[Beats] Metricbeat Docker Compose 기본 구성 하기

Elastic/Beats 2020. 4. 1. 20:38

대부분 올라온 예제가 docker-compose.yml 내 ELKB 구성을 한방에 해서 사용을 하게 되어 있는데,

하고 싶은건 metricbeat 만 컨테이너 기반으로 올려서 agent 형태로 사용하고 다른 노드에서 실행 되고 있는

- Elasticsearch 와

- Kibana 로

통신 하게 하고 싶어서 기록해 봅니다.

 

특별한 내용은 전혀 없습니다.

 

참고문서)

https://www.elastic.co/guide/en/beats/metricbeat/current/running-on-docker.html

 

docker-compose.yml)

version: "3.7"
services:
  metricbeat:
    image: docker.elastic.co/beats/metricbeat:7.6.2
    user: root
    environment:
      - ELASTICSEARCH_HOSTS=http://host.docker.internal:9200
      - KIBANA_HOST=http://host.docker.internal:5601
    network_mode: "host"
    ports:
      - 9200:9200
      - 5601:5601

 

$ docker-compose up -d

 

위 구성은 host 장비에 Elasticsearch 와 Kibana 가 실행 되고 있고,

Metricbeat 를 컨테이너로 실행 시키고 host 장비를 모니터링 하기 위한 구성입니다.

즉, Metricbeat 를 컨테이너 기반의 Agent 로 사용 하는 거라고 보면 될 것 같습니다.

 

관련 문서는 아래 참고 하세요.

https://www.elastic.co/guide/en/beats/metricbeat/current/running-on-docker.html#monitoring-host

 

: