Splunk: Setting default application Id values in _meta
Setting default application Id values in _meta field in Splunk default inputs.conf
@@ -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)
{
