Skip to content

Commit

Permalink
Merge pull request #89 from miazga/master
Browse files Browse the repository at this point in the history
[Feature] Configure collector.syslog.udp.readBufferSize via ENV variable
  • Loading branch information
guptakeshav-sumo authored Jan 22, 2020
2 parents 32ee5d0 + bfeb1d6 commit 0e4c973
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ The following environment variables are supported. You can pass environment vari
|`SUMO_COLLECTOR_HOSTNAME` |Sets the host name of the machine on which the Collector container is running.<br><br> Default: The container ID.|
|`SUMO_DISABLE_SCRIPTS` |If your organization's internal policies restrict the use of scripts, you can disable the creation of script-based script sources. When this parameter is passed, this option is removed from the Sumo web application, and script source cannot be configured.<br><br> Default: false.|
|`SUMO_GENERATE_USER_PROPERTIES`|Set this variable to “false” if you are providing the collector configuration settings using a `user.properties` file via a Docker volume mount.|
|`SUMO_GENERATE_COLLECTOR_PROPERTIES`|Set this variable to “false” if you are providing the collector configuration settings using a `collector.properties` file via a Docker volume mount.|
|`SUMO_JAVA_MEMORY_INIT` |Sets the initial java heap size (in MB). <br><br>Default: 64|
|`SUMO_JAVA_MEMORY_MAX` |Sets the maximum java heap size (in MB). <br><br>Default: 128.|
|`SUMO_PROXY_HOST` |Sets proxy host when a proxy server is used.|
Expand All @@ -143,6 +144,7 @@ The following environment variables are supported. You can pass environment vari
|`SUMO_SOURCES_JSON` |Specifies the path to the `sumo-sources.json` file. <br><br>Default: `/etc/sumo-sources.json`. |
|`SUMO_SYNC_SOURCES` |If “true”, the `SUMO_SOURCES_JSON` file(s) will be continuously monitored and synchronized with the Collector's configuration. This will also disable editing of the collector in the Sumo UI. <br><br>Default: false|
|`SUMO_FIPS_JCE` |If "true", the FIPS 140-2 compliant Java Cryptography Extension (JCE) would be used to encrypt the data. <br><br>Default: false|
|`SUMO_UDP_READ_BUFFER_SIZE` |Sets the datagram size of the UDP messages (in bytes) <br><br>Default: 2048<br><br>Max: 65535|

### Configure collector in user.properties file
You can supply source configuration values using a `user.properties` file via a Docker volume mount. For information about supported properties, see [user.properties](http://help.sumologic.com/Send_Data/Installed_Collectors/05Reference_Information_for_Collector_Installation/06user.properties) in Sumo help. For information about Docker volumes, see [Use Volumes](https://docs.docker.com/engine/admin/volumes/volumes/) in Docker help.
Expand All @@ -156,6 +158,18 @@ For example:
docker run other options -e SUMO_GENERATE_USER_PROPERTIES=false -v $some_path/user.properties:/opt/SumoCollector/config/user.properties sumologic/collector:$tag
```

### Configure collector in collector.properties file
You can supply source configuration values using a `collector.properties` file via a Docker volume mount. For information about supported properties, see [collector.properties](https://help.sumologic.com/03Send-Data/Installed-Collectors/05Reference-Information-for-Collector-Installation/collector.properties) in Sumo help. For information about Docker volumes, see [Use Volumes](https://docs.docker.com/engine/admin/volumes/volumes/) in Docker help.

**Note** If you configure a source using `collector.properties`, you cannot update the source configuration using the Sumo web app or the collector management API.

To use a custom `collector.properties` file, you must pass the environment variable `SUMO_GENERATE_COLLECTOR_PROPERTIES=false`, and provide the Docker volume mount to replace the file located at `/opt/SumoCollector/config/collector.properties`.

For example:
```
docker run other options -e SUMO_GENERATE_COLLECTOR_PROPERTIES=false -v $some_path/collector.properties:/opt/SumoCollector/config/collector.properties sumologic/collector:$tag
```

### To monitor more than 40 containers

By default, you can collect from up to 40 containers. To increase the limit:
Expand Down
27 changes: 27 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if [[ $SUMO_ACCESS_KEY_FILE ]]; then
fi

SUMO_GENERATE_USER_PROPERTIES=${SUMO_GENERATE_USER_PROPERTIES:=true}
SUMO_GENERATE_COLLECTOR_PROPERTIES=${SUMO_GENERATE_COLLECTOR_PROPERTIES:=true}
SUMO_ACCESS_ID=${SUMO_ACCESS_ID:=$1}
SUMO_ACCESS_KEY=${SUMO_ACCESS_KEY:=$2}
SUMO_RECEIVER_URL=${SUMO_RECEIVER_URL:=https://collectors.sumologic.com}
Expand All @@ -19,6 +20,27 @@ SUMO_SYNC_SOURCES=${SUMO_SYNC_SOURCES:=false}
SUMO_COLLECTOR_EPHEMERAL=${SUMO_COLLECTOR_EPHEMERAL:=true}
SUMO_COLLECTOR_HOSTNAME=${SUMO_COLLECTOR_HOSTNAME:=$(cat /etc/hostname)}

generate_collector_properties_file() {
# Read values from ENV variables and place them in collector/config/collector.properties file
declare -A SUPPORTED_OPTIONS
SUPPORTED_OPTIONS=(
["SUMO_UDP_READ_BUFFER_SIZE"]="collector.syslog.udp.readBufferSize"
)
COLLECTOR_PROPERTIES=""

for key in "${!SUPPORTED_OPTIONS[@]}"
do
value=${!key}
if [ -n "${value}" ]; then
COLLECTOR_PROPERTIES="${COLLECTOR_PROPERTIES}${SUPPORTED_OPTIONS[$key]}=${value}\n"
fi
done

if [ -n "${COLLECTOR_PROPERTIES}" ]; then
echo -e ${COLLECTOR_PROPERTIES} > /opt/SumoCollector/config/collector.properties
fi
}

generate_user_properties_file() {
if [ -z "$SUMO_ACCESS_ID" ] || [ -z "$SUMO_ACCESS_KEY" ]; then
echo "FATAL: Please provide credentials, either via the SUMO_ACCESS_ID and SUMO_ACCESS_KEY environment variables,"
Expand Down Expand Up @@ -114,6 +136,11 @@ $SUMO_GENERATE_USER_PROPERTIES && {
generate_user_properties_file
}

# If the user didn't supply their own collector.properties file, generate it
$SUMO_GENERATE_COLLECTOR_PROPERTIES && {
generate_collector_properties_file
}

if [ "${SUMO_FIPS_JCE}" == "true" ]; then
/opt/SumoCollector/script/configureFipsMode.sh
fi
Expand Down

0 comments on commit 0e4c973

Please sign in to comment.