Herramientas de usuario

Herramientas del sitio


wiki2:fluentd

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anterior Revisión previa
Próxima revisión
Revisión previa
wiki2:fluentd [2015/05/06 14:38]
alfred
wiki2:fluentd [2020/05/09 09:25] (actual)
Línea 1: Línea 1:
 ====== Fluentd ====== ====== Fluentd ======
 +
 +It is a service to manage system logs. It takes logs from software (MySQL, Apache, the system...) and unify their format and send them to the required place.
 +
 Also called td-agent. Also called td-agent.
  
-By default, ​/etc/td-agent/​td-agent.conf is configured to take logs from HTTP and route them to stdout (/var/log/td-agent/​td-agent.log). You can post sample log records using the curl command.+Before install: http://docs.fluentd.org/articles/before-install
  
-''​$ curl -X POST -d '​json={"​json":"​message"​}'​ http://​localhost:​8888/​debug.test''​+By default, td-agent is configured to take logs from HTTP and route them to stdout (''/​var/​log/​td-agent/​td-agent.log''​). You can post sample log records using the curl command: ​''​$ curl -X POST -d '​json={"​json":"​message"​}'​ http://​localhost:​8888/​debug.test''​
  
 <​code>​ <​code>​
Línea 30: Línea 33:
 The “match” directive looks for events with _match_ing tags and tells Fluentd what to do. The “match” directive looks for events with _match_ing tags and tells Fluentd what to do.
  
 +
 +==== Plugins ====
 +
 +Install plugins: ''​$ /​usr/​sbin/​td-agent-gem install fluent-plugin-xx''​
 +
 +  * For replication use the out_copy plugin.
 +
 +=== Fluentd-ui ===
 +
 +  * https://​github.com/​fluent/​fluentd-ui
 +  * Install: $ /​usr/​sbin/​td-agent-gem install -V fluentd-ui
 +  * Start: ''/​opt/​td-agent/​embedded/​bin/​fluentd-ui start''​
 +
 +==== Python ====
 +Libraries: ​
 +  * [[https://​pypi.python.org/​pypi/​fluent-logger/​|fluent-logger]]
 +  * [[https://​pypi.python.org/​pypi/​pyfluent|pyfluent]]
 +
 +=== Fluentd-logger ===
 +<code python>
 +from fluent import sender, event
 +sender.setup('​debug.test',​ host='​127.0.0.1',​ port=24224)
 +event.Event('​json',​ {"​json":"​message from python"​})
 +</​code>​
 +
 +=== pyfluent ===
 +<code python>
 +import logging
 +from pyfluent.logging import SafeFluentHandler
 +handler = SafeFluentHandler('​localhost',​ 24224, '​pyfluent'​)
 +handler.setLevel(logging.INFO)
 +logger = logging.getLogger()
 +logger.setLevel(logging.INFO)
 +logger.addHandler(handler)
 +logger.info('​hello pyfluent!'​)
 +</​code>​
 +
 +<code python>
 +import logging
 +import logging.config
 +
 +logger = logging.getLogger(__name__)
 +
 +logging.config.dictConfig({
 +    '​version':​ 1,              ​
 +    '​disable_existing_loggers':​ False, ​ # this fixes the problem
 +
 +    '​handlers':​ {
 +        '​fluentd':​ {
 +            '​level':​ '​DEBUG',​
 +            '​class':​ '​pyfluent.logging.SafeFluentHandler',​
 +            '​tag':​ '​test.prueba',​
 +        },
 +    },
 +    '​loggers':​ {
 +        '':​ {                  ​
 +            '​handlers':​ ['​fluentd'​], ​       ​
 +            '​level':​ '​INFO'​
 +        }
 +    }
 +})
 +
 +logger.info('​It works!'​)
 +</​code>​
wiki2/fluentd.1430923115.txt.gz · Última modificación: 2020/05/09 09:24 (editor externo)