Dashboards & Visualizations

Is it possible to access properties from a custom config file (props.conf) in a Simple XML extension?

kbarker302
Communicator

I would like to access properties from a custom config file in a Simple XML extension - is this possible? For now, I am just trying to access the props.conf from the default search app using the following code, which is based on the SplunkJS SDK documentation:

var files = svc.configurations( 
{    
  app: "search",
  owner: "admin"
});

files.item("props", function(err, propsFile) {
    propsFile.fetch(function(err, props) {
    console.log(props.properties()); 
  });
}); 

However, I am unsure how to instantiate the svc (splunkjs.Service) object for a Simple XML extension. I have tried instantiating it like this:

var http = new splunkjs.ProxyHttp("/proxy");
var svc = new splunkjs.Service(http, {
    username: "admin",
    password: "changeme",
    scheme: "https",
    host: "localhost",
    port:"8089",
    version:"6.3.0"
});

and it does give me a configurations object, but the result is always null.

Any help would be greatly appreciated.

0 Karma
1 Solution

kbarker302
Communicator

For the record, I was able to accomplish what I wanted using the following code:

require([
    "splunkjs/mvc",
    "splunkjs/mvc/simplexml/ready!"
], function(
 mvc
) {
    mvc.createService().get("/servicesNS/-/search/configs/conf-props",{},function(err,response) {
        content=response.data.entry[0].content;
    }); 
}); 

This returns a content object that contains the properties I was looking for, which can be queried as necessary.

H/T to the following code on GitHub - the _get_api_key function posted there got me pointed in the right direction:

https://github.com/CartoDB/cartodb-splunk/blob/master/appserver/static/cartodb/cartodb.js

View solution in original post

kbarker302
Communicator

For the record, I was able to accomplish what I wanted using the following code:

require([
    "splunkjs/mvc",
    "splunkjs/mvc/simplexml/ready!"
], function(
 mvc
) {
    mvc.createService().get("/servicesNS/-/search/configs/conf-props",{},function(err,response) {
        content=response.data.entry[0].content;
    }); 
}); 

This returns a content object that contains the properties I was looking for, which can be queried as necessary.

H/T to the following code on GitHub - the _get_api_key function posted there got me pointed in the right direction:

https://github.com/CartoDB/cartodb-splunk/blob/master/appserver/static/cartodb/cartodb.js

Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...