mirror of
https://github.com/ceph/ceph
synced 2025-02-16 15:27:47 +00:00
log: set hostname and fsid for graylog
in which, hostname is mandatory per https://docs.graylog.org/en/4.0/pages/gelf.html#gelf-payload-specification, so without this change, if user enables `log_to_graylog` and/or `err_to_graylog`, failures like java.lang.IllegalArgumentException: GELF message <ed6876e1-9265-11ea-bc94-1ad2db8b5489> (received from <10.10.10.12:36509>) has empty mandatory "host" field. is expected. after this change, this field is set. Fixes: https://tracker.ceph.com/issues/45457 Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
3bee326025
commit
0bedd067be
@ -31,6 +31,7 @@
|
||||
#include "common/debug.h"
|
||||
#include "common/config.h"
|
||||
#include "common/ceph_crypto.h"
|
||||
#include "common/hostname.h"
|
||||
#include "common/HeartbeatMap.h"
|
||||
#include "common/errno.h"
|
||||
#include "common/Graylog.h"
|
||||
@ -346,7 +347,7 @@ public:
|
||||
log->set_graylog_level(l, l);
|
||||
|
||||
if (conf->log_to_graylog || conf->err_to_graylog) {
|
||||
log->start_graylog();
|
||||
log->start_graylog(conf->host, conf.get_val<uuid_d>("fsid"));
|
||||
} else if (! (conf->log_to_graylog && conf->err_to_graylog)) {
|
||||
log->stop_graylog();
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "include/ceph_assert.h"
|
||||
#include "include/compat.h"
|
||||
#include "include/on_exit.h"
|
||||
#include "include/uuid.h"
|
||||
|
||||
#include "Entry.h"
|
||||
#include "LogClock.h"
|
||||
@ -165,11 +166,15 @@ void Log::set_graylog_level(int log, int crash)
|
||||
m_graylog_crash = crash;
|
||||
}
|
||||
|
||||
void Log::start_graylog()
|
||||
void Log::start_graylog(const std::string& host,
|
||||
const uuid_d& fsid)
|
||||
{
|
||||
std::scoped_lock lock(m_flush_mutex);
|
||||
if (! m_graylog.get())
|
||||
if (! m_graylog.get()) {
|
||||
m_graylog = std::make_shared<Graylog>(m_subs, "dlog");
|
||||
m_graylog->set_hostname(host);
|
||||
m_graylog->set_fsid(fsid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "log/Entry.h"
|
||||
|
||||
struct uuid_d;
|
||||
|
||||
namespace ceph {
|
||||
namespace logging {
|
||||
|
||||
@ -107,7 +109,8 @@ public:
|
||||
void set_stderr_level(int log, int crash);
|
||||
void set_graylog_level(int log, int crash);
|
||||
|
||||
void start_graylog();
|
||||
void start_graylog(const std::string& host,
|
||||
const uuid_d& fsid);
|
||||
void stop_graylog();
|
||||
|
||||
void set_journald_level(int log, int crash);
|
||||
|
Loading…
Reference in New Issue
Block a user