=yaml
{{tag>development addendum}}
[[http://yaml.org/]]
== conceptos básicos
* diccionarios: ''key: value''
* listas: ''- item''
== elastic?
=== namespacing
* ''output.elasticsearch.index: ... ''
output:
elasticsearch:
index: 'beat-%{[beat.version]}-%{+yyyy.MM.dd}'
* ''filebeat.inputs.0.type: log''
filebeat:
inputs:
- type: log
=== data types
* boolean
* number
* string:
* comillas dobles (permite escapar caracteres, implica escapar las comillas y la barra invertida)
* comillas simnples (no permite escapar caracteres)
* sin comillas (no permite escapar caracteres, ojo con caracteres con significado en YAML)
* duration:
* valor numérico + unidad -> ns, us, ms, s, m, h
* regex
* recomendado entre comillas simples
* format string
* permite referenciar variables -> %{:valor_defecto}
* también [variable]
=== variables de entorno
* ''${VAR}'' : definición
* ''${VAR:default_value}'' : definición con valor por defecto
* ''${VAR:?error_text}'' : se añade **error_text** al mensaje de error si no se puede acceder a ${VAR}
* ES_HOSTS="10.45.3.2:9220,10.45.3.1:9230"
se convierte en lista:
output.elasticseach:
hosts: '${ES_HOSTS}'
=== variables referenciadas
* pasando por línea de comando ''-E es-host=another-host'':#establece localhost por defecto si no se le pasa variable
es.host: '${ES_HOST:localhost}'
output.elasticsearch:
hosts: ['http://${es.host}:9200']
* sustituciones de bloque:namespace1:
subnamespace:
host: localhost
sleep: 1s
namespace2:
subnamespace:
host: localhost
sleep: 1s
por namespace1: ${shared}
namespace2: ${shared}
shared:
subnamespace:
host: localhost
sleep: 1s
=== test
* ''beatname test config -c beatname.yml''