我是Docker和Graylog的新手.谁能告诉我一个如何将日志数据发送到Graylog服务器的示例?
import logging
import graypy
my_logger = logging.getLogger('test_logger')
my_logger.setLevel(logging.DEBUG)
handler = graypy.GELFHandler('my_graylog_server', 12201)
my_logger.addHandler(handler)
my_adapter = logging.LoggerAdapter(logging.getLogger('test_logger'),
{ 'username': 'John' })
my_adapter.debug('Hello Graylog2 from John.')
Run Code Online (Sandbox Code Playgroud)
不管用
我认为问题是应该发送到的URL,/gelf
因为当我从终端卷曲到我的graylog服务器时,它可以工作
curl -XPOST http://my_graylog_server:12201/gelf -p0 -d '{"short_message":"Hello there", "host":"example1111.org", "facility":"test", "_foo":"bar"}'
Run Code Online (Sandbox Code Playgroud) 我正在尝试将 Web 服务输入/输出作为 xml 插入 Graylog 中。为此,我使用了“GELFJ - 用于 Log4j 的 GELF Appender 和用于 JDK Logging 的 GELF Handler”。这是示例代码:
public static void main(String[] args) throws IOException {
GelfSender gelfSender = new GelfTCPSender("172.21.120.139", 12201);
String xmlMessage = readFile("c:\\temp\\xml.xml");
GelfMessage message = new GelfMessage("short message", "long message", System.currentTimeMillis(), "1");
message.setHost("localhost");
message.addField("XML", xmlMessage);
message.addField("LEN", xmlMessage.length());
if (message.isValid()) {
GelfSenderResult result = gelfSender.sendMessage(message);
Exception exception = result.getException();
if (exception != null) {
exception.printStackTrace();
}
} else {
System.err.println("Message is not valid!");
}
}
Run Code Online (Sandbox Code Playgroud)
这是 …
如何将每个日志文件名从 Filebeat 传递到 Logstash?
我想在 Graylog 中查看源文件名以进行深入分析。
我研究了文档但没有找到解释。你能帮助我吗?
我的 elasticsearch 集群“graylog2”健康状态显示为黄色,但在网络界面中显示为绿色。
我可以在 Graylog 网络界面中看到以下几行。
“1个索引,共管理26条消息,当前写活动索引为graylog2_0。
Elasticsearch 集群是绿色的。分片:1 个活动,0 个初始化,0 个重新定位,0 个未分配”
http://127.0.0.1:9200/_cluster/health?pretty=true
{
"cluster_name" : "graylog2",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 2,
"number_of_data_nodes" : 1,
"active_primary_shards" : 6,
"active_shards" : 6,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 5,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0
}
http://127.0.0.1:9200/_cat/indices?v
health status index pri rep docs.count docs.deleted store.size pri.store.size
yellow open logstash-2016.03.17 5 1 27 0 37.4kb 37.4kb
green open graylog2_0 1 0 26 …Run Code Online (Sandbox Code Playgroud)