diff options
author | Bjørn Meland <bjormel@users.noreply.github.com> | 2020-02-14 14:23:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-14 14:23:58 +0100 |
commit | 0e77350cf98884bd98235a051873dc7074c629f9 (patch) | |
tree | 1dc5a7357f8444b07436ead2ebe71db36603eb80 | |
parent | 4146f90e676b3a83204b8992198bb0b0eb553e01 (diff) |
Splunk: Setting default application Id values in _meta (#12182)
Setting default application Id values in _meta field in Splunk default inputs.conf
-rw-r--r-- | logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp b/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp index addf9125508..22550a19383 100644 --- a/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp +++ b/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp @@ -46,10 +46,11 @@ bool fixDir(const vespalib::string &path) { } vespalib::string -cfFilePath(const vespalib::string &parent) { +cfFilePath(const vespalib::string &parent, const vespalib::string &filename) { vespalib::string path = parent + "/etc/system/local"; fixDir(path); - path += "/deploymentclient.conf"; + path += "/"; + path += filename; return path; } @@ -61,7 +62,7 @@ CfHandler::doConfigure() std::unique_ptr<LogforwarderConfig> cfg(_handle->getConfig()); const LogforwarderConfig& config(*cfg); - vespalib::string path = cfFilePath(config.splunkHome); + vespalib::string path = cfFilePath(config.splunkHome, "deploymentclient.conf"); vespalib::string tmpPath = path + ".new"; FILE *fp = fopen(tmpPath.c_str(), "w"); if (fp == NULL) return; @@ -76,6 +77,22 @@ CfHandler::doConfigure() fclose(fp); rename(tmpPath.c_str(), path.c_str()); + if (getenv("VESPA_HOSTNAME") != NULL && + getenv("VESPA_TENANT") != NULL && + getenv("VESPA_APPLICATION")!= NULL && + getenv("VESPA_INSTANCE") != NULL ) + { + path = cfFilePath(config.splunkHome, "inputs.conf"); + tmpPath = path + ".new"; + fp = fopen(tmpPath.c_str(), "w"); + if (fp != NULL) { + fprintf(fp, "[default]\n"); + fprintf(fp, "host = %s\n", getenv("VESPA_HOSTNAME")); + fprintf(fp, "_meta = vespa_tenant::%s vespa_application::%s vespa_instance::%s\n", getenv("VESPA_TENANT"), getenv("VESPA_APPLICATION"), getenv("VESPA_INSTANCE")); + fclose(fp); + rename(tmpPath.c_str(), path.c_str()); + } + } if (config.clientName.size() == 0 || config.deploymentServer.size() == 0) { |