I was recently asked if it was possible to automate the configuration of Log Insight agents. More specifically, the request was to modify an agent configuration as new applications were brought up on a system. In this post, I will cover a couple of ways to automate agent configuration.
Assuming you are automating application standup on the client side, as part of the automation you could configure the Log Insight agent. This can be done by editing the liagent.ini file. To ease configuration management you could use a configuration management tool like Puppet or if you are comfortable managing the configuration yourself you could add it to the application automation you are already leveraging.
Since there are a lot of configuration management tools out there and the liagent.ini is well documented, I will leave client-side automation up to you.
If you are looking for an easy way to handle agent configuration management for both Windows and Linux then I would recommend server-side configuration. While there is no configuration API today, since server-side configuration is possible from the UI, automation via cURL commands is possible. In short, you will need to get a cookie, authenticate with Log Insight, and save a new agent configuration. Below is a script that will do that for you.
- The below script requires that the agent configuration be put in a separate file that is passed to the script
- Since this is a server-side configuration, only filelog and winlog configuration can be passed
- The configuration passed to the script will OVERRIDE any existing server-side configuration so be sure you are merging your changes with the current configuration.
#!/usr/bin/env bash LI_FQDN=loginsight.example.com LI_ADMIN_USERNAME=admin LI_ADMIN_PASSWD=password if [ -z "$1" ]; then echo "USAGE: $0 "; exit; else CONFIG=$1; fi # get a session id curl --insecure -c cookies https://$LI_FQDN/ # authenticate curl --insecure -b cookies --data 'username=$LI_ADMIN_USERNAME&password=$LI_ADMIN_PASSWD&login=Login' https://$LI_FQDN/login # modify agent configuration curl -b cookies --insecure --data-urlencode "agentConfigText=$(cat $CONFIG)" -d "_eventName=applyAgentsConfig" https://$LI_FQDN/admin/agents
© 2015, Steve Flanders. All rights reserved.