mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-12-04 17:56:07 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6a08c776b |
No files matched your search
@@ -17,10 +17,7 @@ elasticsearch:
|
|||||||
global: True
|
global: True
|
||||||
advanced: True
|
advanced: True
|
||||||
esheap:
|
esheap:
|
||||||
description: Heap size to use for Elasticsearch, as a number followed by k (kilobytes), m (megabytes) or g (gigabytes), such as 600m.
|
description: Specify the memory heap size in (m)egabytes for Elasticsearch.
|
||||||
forcedType: string
|
|
||||||
regex: ^[1-9][0-9]*[kKmMgG]$
|
|
||||||
regexFailureMessage: Must be a whole number followed by k, m or g, such as 600m.
|
|
||||||
helpLink: elasticsearch
|
helpLink: elasticsearch
|
||||||
index_clean:
|
index_clean:
|
||||||
description: Determines if indices should be considered for deletion by available disk space in the cluster. Otherwise, data is retained by the configured lifecycle settings. This setting only applies to EVAL, STANDALONE, and HEAVY NODE installations. Other installations use lifecycle settings only.
|
description: Determines if indices should be considered for deletion by available disk space in the cluster. Otherwise, data is retained by the configured lifecycle settings. This setting only applies to EVAL, STANDALONE, and HEAVY NODE installations. Other installations use lifecycle settings only.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{% from 'vars/globals.map.jinja' import GLOBALS %}
|
{% from 'vars/globals.map.jinja' import GLOBALS %}
|
||||||
|
{% from 'telegraf/map.jinja' import INFLUX_RETIRED %}
|
||||||
|
|
||||||
{% if GLOBALS.role == 'so-eval' %}
|
{% if GLOBALS.role == 'so-eval' %}
|
||||||
{% set NODE_CONTAINERS = [
|
{% set NODE_CONTAINERS = [
|
||||||
@@ -109,3 +110,7 @@
|
|||||||
{% set NODE_CONTAINERS = [] %}
|
{% set NODE_CONTAINERS = [] %}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if INFLUX_RETIRED and 'so-influxdb' in NODE_CONTAINERS %}
|
||||||
|
{% do NODE_CONTAINERS.remove('so-influxdb') %}
|
||||||
|
{% endif %}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{% from 'vars/globals.map.jinja' import GLOBALS %}
|
{% from 'vars/globals.map.jinja' import GLOBALS %}
|
||||||
{% from 'docker/docker.map.jinja' import DOCKERMERGED %}
|
{% from 'docker/docker.map.jinja' import DOCKERMERGED %}
|
||||||
|
{% from 'telegraf/map.jinja' import INFLUX_RETIRED %}
|
||||||
{% import_yaml 'firewall/defaults.yaml' as FIREWALL_DEFAULT %}
|
{% import_yaml 'firewall/defaults.yaml' as FIREWALL_DEFAULT %}
|
||||||
|
|
||||||
{# add our ip to self #}
|
{# add our ip to self #}
|
||||||
@@ -60,3 +61,12 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% set FIREWALL_MERGED = salt['pillar.get']('firewall', FIREWALL_DEFAULT.firewall, merge=True) %}
|
{% set FIREWALL_MERGED = salt['pillar.get']('firewall', FIREWALL_DEFAULT.firewall, merge=True) %}
|
||||||
|
|
||||||
|
{# filtered after the merge so portgroup lists saved in Configuration lose influxdb too #}
|
||||||
|
{% if INFLUX_RETIRED and (role.startswith('manager') or role in ['eval', 'standalone', 'import']) %}
|
||||||
|
{% for hostgroup in FIREWALL_MERGED.role[role].chain['DOCKER-USER'].hostgroups.values() %}
|
||||||
|
{% if 'influxdb' in hostgroup.get('portgroups', []) %}
|
||||||
|
{% do hostgroup.update({'portgroups': hostgroup.portgroups | reject('equalto', 'influxdb') | list}) %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
@@ -4,9 +4,12 @@
|
|||||||
# Elastic License 2.0.
|
# Elastic License 2.0.
|
||||||
|
|
||||||
{% from 'influxdb/map.jinja' import INFLUXMERGED %}
|
{% from 'influxdb/map.jinja' import INFLUXMERGED %}
|
||||||
|
{% from 'telegraf/map.jinja' import INFLUX_RETIRED %}
|
||||||
|
|
||||||
include:
|
include:
|
||||||
{% if INFLUXMERGED.enabled %}
|
{% if INFLUX_RETIRED %}
|
||||||
|
- influxdb.retired
|
||||||
|
{% elif INFLUXMERGED.enabled %}
|
||||||
- influxdb.enabled
|
- influxdb.enabled
|
||||||
{% else %}
|
{% else %}
|
||||||
- influxdb.disabled
|
- influxdb.disabled
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
|
||||||
|
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
|
||||||
|
# https://securityonion.net/license; you may not use this file except in compliance with the
|
||||||
|
# Elastic License 2.0.
|
||||||
|
|
||||||
|
{% from 'allowed_states.map.jinja' import allowed_states %}
|
||||||
|
{% if sls.split('.')[0] in allowed_states %}
|
||||||
|
|
||||||
|
include:
|
||||||
|
- influxdb.disabled
|
||||||
|
|
||||||
|
influxdb_data_purged:
|
||||||
|
file.directory:
|
||||||
|
- name: /nsm/influxdb
|
||||||
|
- clean: True
|
||||||
|
- require:
|
||||||
|
- docker_container: so-influxdb
|
||||||
|
|
||||||
|
influxdb_conf_purged:
|
||||||
|
file.absent:
|
||||||
|
- name: /opt/so/conf/influxdb
|
||||||
|
- require:
|
||||||
|
- docker_container: so-influxdb
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{{sls}}_state_not_allowed:
|
||||||
|
test.fail_without_changes:
|
||||||
|
- name: {{sls}}_state_not_allowed
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
influxdb:
|
influxdb:
|
||||||
enabled:
|
enabled:
|
||||||
description: Enables the grid metrics collection storage system. Security Onion grid health monitoring requires this process to remain enabled. WARNING - Disabling the process is unsupported, and will cause unexpected results.
|
description: Enables the grid metrics collection storage system. Security Onion grid health monitoring requires this process to remain enabled. WARNING - Disabling the process is unsupported, and will cause unexpected results. This setting has no effect when telegraf.output is POSTGRES.
|
||||||
forcedType: bool
|
forcedType: bool
|
||||||
helpLink: influxdb
|
helpLink: influxdb
|
||||||
config:
|
config:
|
||||||
|
|||||||
@@ -404,10 +404,7 @@ logstash:
|
|||||||
custom9: *pipeline_settings
|
custom9: *pipeline_settings
|
||||||
settings:
|
settings:
|
||||||
lsheap:
|
lsheap:
|
||||||
description: Heap size to use for Logstash, as a number followed by k (kilobytes), m (megabytes) or g (gigabytes), such as 500m.
|
description: Heap size to use for logstash
|
||||||
forcedType: string
|
|
||||||
regex: ^[1-9][0-9]*[kKmMgG]$
|
|
||||||
regexFailureMessage: Must be a whole number followed by k, m or g, such as 500m.
|
|
||||||
helpLink: logstash
|
helpLink: logstash
|
||||||
global: False
|
global: False
|
||||||
config:
|
config:
|
||||||
|
|||||||
@@ -399,6 +399,16 @@ function syncElastic() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function syncInfluxdbUser() {
|
||||||
|
local op=$1
|
||||||
|
local email=$2
|
||||||
|
if ! docker ps -a --format '{{.Names}}' < /dev/null | grep -qx so-influxdb; then
|
||||||
|
echo "Skipped InfluxDB $op for $email: the so-influxdb container does not exist, so InfluxDB was not changed." >&2
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
so-influxdb-manage "$op" "$email"
|
||||||
|
}
|
||||||
|
|
||||||
function syncAll() {
|
function syncAll() {
|
||||||
ensureRoleFileExists
|
ensureRoleFileExists
|
||||||
|
|
||||||
@@ -594,9 +604,9 @@ case "${operation}" in
|
|||||||
createUser "$email" "${role:-$DEFAULT_ROLE}" "${firstName}" "${lastName}" "${note}"
|
createUser "$email" "${role:-$DEFAULT_ROLE}" "${firstName}" "${lastName}" "${note}"
|
||||||
syncAll
|
syncAll
|
||||||
echo "Successfully added new user to SOC"
|
echo "Successfully added new user to SOC"
|
||||||
echo "$password" | so-influxdb-manage useradd "$email"
|
echo "$password" | syncInfluxdbUser useradd "$email"
|
||||||
if [[ "$role" == "superuser" ]]; then
|
if [[ "$role" == "superuser" ]]; then
|
||||||
echo "$password" | so-influxdb-manage userpromote "$email"
|
echo "$password" | syncInfluxdbUser userpromote "$email"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -616,7 +626,7 @@ case "${operation}" in
|
|||||||
syncElastic
|
syncElastic
|
||||||
echo "Successfully added role to user"
|
echo "Successfully added role to user"
|
||||||
if [[ "$role" == "superuser" ]]; then
|
if [[ "$role" == "superuser" ]]; then
|
||||||
echo "$password" | so-influxdb-manage userpromote "$email"
|
echo "$password" | syncInfluxdbUser userpromote "$email"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@@ -632,7 +642,7 @@ case "${operation}" in
|
|||||||
syncElastic
|
syncElastic
|
||||||
echo "Successfully removed role from user"
|
echo "Successfully removed role from user"
|
||||||
if [[ "$role" == "superuser" ]]; then
|
if [[ "$role" == "superuser" ]]; then
|
||||||
echo "$password" | so-influxdb-manage userdemote "$email"
|
echo "$password" | syncInfluxdbUser userdemote "$email"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -644,7 +654,7 @@ case "${operation}" in
|
|||||||
updateUserPassword "$email"
|
updateUserPassword "$email"
|
||||||
syncAll
|
syncAll
|
||||||
echo "Successfully updated user password"
|
echo "Successfully updated user password"
|
||||||
echo "$password" | so-influxdb-manage userpass "$email"
|
echo "$password" | syncInfluxdbUser userpass "$email"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"profile")
|
"profile")
|
||||||
@@ -664,7 +674,7 @@ case "${operation}" in
|
|||||||
updateStatus "$email" 'active'
|
updateStatus "$email" 'active'
|
||||||
syncAll
|
syncAll
|
||||||
echo "Successfully enabled user"
|
echo "Successfully enabled user"
|
||||||
so-influxdb-manage userenable "$email"
|
syncInfluxdbUser userenable "$email"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"disable")
|
"disable")
|
||||||
@@ -675,7 +685,7 @@ case "${operation}" in
|
|||||||
updateStatus "$email" 'locked'
|
updateStatus "$email" 'locked'
|
||||||
syncAll
|
syncAll
|
||||||
echo "Successfully disabled user"
|
echo "Successfully disabled user"
|
||||||
so-influxdb-manage userdisable "$email"
|
syncInfluxdbUser userdisable "$email"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"delete")
|
"delete")
|
||||||
@@ -686,7 +696,7 @@ case "${operation}" in
|
|||||||
deleteUser "$email"
|
deleteUser "$email"
|
||||||
syncAll
|
syncAll
|
||||||
echo "Successfully deleted user"
|
echo "Successfully deleted user"
|
||||||
so-influxdb-manage userdel "$email"
|
syncInfluxdbUser userdel "$email"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"sync")
|
"sync")
|
||||||
|
|||||||
@@ -361,6 +361,187 @@ check_fleet_server() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TELEGRAF_PILLAR=/opt/so/saltstack/local/pillar/telegraf/soc_telegraf.sls
|
||||||
|
TELEGRAF_CREDS=/opt/so/saltstack/local/pillar/telegraf/creds.sls
|
||||||
|
INFLUXDB_DIRS=(/nsm/influxdb /opt/so/conf/influxdb)
|
||||||
|
|
||||||
|
telegraf_creds_present() {
|
||||||
|
local mid=$1
|
||||||
|
[[ -n $(so-yaml.py get -r "$TELEGRAF_CREDS" "telegraf.postgres_creds.${mid}.user" 2>/dev/null) ]] &&
|
||||||
|
[[ -n $(so-yaml.py get -r "$TELEGRAF_CREDS" "telegraf.postgres_creds.${mid}.pass" 2>/dev/null) ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
# An unreadable docker or directory state counts as present so the POSTGRES path
|
||||||
|
# asks, or refuses on -y, rather than letting a highstate delete data unannounced.
|
||||||
|
influxdb_container_exists() {
|
||||||
|
local names
|
||||||
|
names=$(docker ps -a --format '{{.Names}}' 2>/dev/null) || return 0
|
||||||
|
grep -qx so-influxdb <<< "$names"
|
||||||
|
}
|
||||||
|
|
||||||
|
influxdb_present() {
|
||||||
|
local dir contents
|
||||||
|
influxdb_container_exists && return 0
|
||||||
|
for dir in "${INFLUXDB_DIRS[@]}"; do
|
||||||
|
[[ -e $dir ]] || continue
|
||||||
|
contents=$(ls -A "$dir" 2>/dev/null) || return 0
|
||||||
|
[[ -n $contents ]] && return 0
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
set_influxdb_size() {
|
||||||
|
local dir
|
||||||
|
local -a existing=()
|
||||||
|
for dir in "${INFLUXDB_DIRS[@]}"; do
|
||||||
|
[[ -e $dir ]] && existing+=("$dir")
|
||||||
|
done
|
||||||
|
INFLUXDB_SIZE=0
|
||||||
|
(( ${#existing[@]} == 0 )) && return 0
|
||||||
|
if ! INFLUXDB_SIZE=$(set -o pipefail; du -sch "${existing[@]}" 2>/dev/null | tail -n 1 | cut -f1) || [[ -z $INFLUXDB_SIZE ]]; then
|
||||||
|
FINAL_MESSAGE_QUEUE+=("WARNING: Unable to measure the size of InfluxDB's data in ${INFLUXDB_DIRS[*]}.")
|
||||||
|
INFLUXDB_SIZE="an unknown amount"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
influxdb_switch_prompt() {
|
||||||
|
local output answer mid mids
|
||||||
|
local -a missing=()
|
||||||
|
|
||||||
|
# read the pillar files rather than salt, as influxdb_switch_apply must while salt-master is stopped
|
||||||
|
output=$(so-yaml.py get -r "$TELEGRAF_PILLAR" telegraf.output 2>/dev/null) ||
|
||||||
|
output=$(so-yaml.py get -r "$DEFAULT_SALT_DIR/salt/telegraf/defaults.yaml" telegraf.output 2>/dev/null) ||
|
||||||
|
output=INFLUXDB
|
||||||
|
output=${output^^}
|
||||||
|
|
||||||
|
if [[ "$output" == "POSTGRES" ]]; then
|
||||||
|
if ! telegraf_creds_present "$MINIONID"; then
|
||||||
|
echo ""
|
||||||
|
echo "The metrics output is POSTGRES, but this manager has no Telegraf Postgres credentials."
|
||||||
|
echo "The upgrade cannot complete without them. soup has not changed anything."
|
||||||
|
echo ""
|
||||||
|
echo "Add them, then run soup again:"
|
||||||
|
echo " sudo so-telegraf-cred add $MINIONID"
|
||||||
|
echo ""
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
influxdb_present || return 0
|
||||||
|
set_influxdb_size
|
||||||
|
|
||||||
|
if [[ -n $UNATTENDED ]]; then
|
||||||
|
if [[ -n $DELETES_ACCEPTED ]]; then
|
||||||
|
INFLUX_DELETE_ACCEPTED=1
|
||||||
|
echo "InfluxDB ($INFLUXDB_SIZE) is still present on this POSTGRES grid; its deletion was accepted with --deletes-accepted."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
echo "The metrics output is POSTGRES, so this upgrade would remove InfluxDB and delete"
|
||||||
|
echo "all of its data ($INFLUXDB_SIZE). The deletion cannot be undone. soup has not changed anything."
|
||||||
|
echo ""
|
||||||
|
echo "To continue, choose one of the following:"
|
||||||
|
echo " - Accept the deletion: sudo soup -y --deletes-accepted"
|
||||||
|
echo " - Confirm the deletion at the prompt: sudo soup"
|
||||||
|
echo " - Save the data if needed and remove InfluxDB by hand, then run sudo soup -y again:"
|
||||||
|
# the installed release's scheduled highstate would otherwise start InfluxDB again before soup runs
|
||||||
|
echo " sudo so-yaml.py replace /opt/so/saltstack/local/pillar/minions/$MINIONID.sls influxdb.enabled false"
|
||||||
|
echo " sudo docker rm -f so-influxdb"
|
||||||
|
echo " sudo find ${INFLUXDB_DIRS[*]} -mindepth 1 -delete"
|
||||||
|
echo ""
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "The metrics output is POSTGRES, but InfluxDB is still on this manager with $INFLUXDB_SIZE"
|
||||||
|
echo "of old data. This upgrade removes InfluxDB and deletes all of that data, and the"
|
||||||
|
echo "deletion cannot be undone."
|
||||||
|
echo "Exit now if you want to save or export the data first, then run soup again."
|
||||||
|
echo ""
|
||||||
|
read -rp "Press C to continue with the upgrade or E to exit: " answer
|
||||||
|
if [[ "$answer" != [cC] ]]; then
|
||||||
|
echo "Exiting soup"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# releases before 3.1.0 have no Telegraf credentials; influxdb_switch_apply creates them on a switch
|
||||||
|
[[ $INSTALLEDVERSION =~ ^(2\.|3\.0\.) ]] && INFLUX_CREATE_CREDS=1
|
||||||
|
|
||||||
|
if ! mids=$(salt-key --out=json --list=accepted 2>/dev/null | jq -r '.minions[]?' 2>/dev/null) || [[ -z $mids ]]; then
|
||||||
|
missing=("(unable to list accepted minions)")
|
||||||
|
else
|
||||||
|
INFLUX_SWITCH_MINIONS=$mids
|
||||||
|
if [[ -z $INFLUX_CREATE_CREDS ]]; then
|
||||||
|
for mid in $mids; do
|
||||||
|
telegraf_creds_present "$mid" || missing+=("$mid")
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if (( ${#missing[@]} > 0 )); then
|
||||||
|
FINAL_MESSAGE_QUEUE+=("NOTE: soup did not offer to move metrics from InfluxDB to Postgres because these nodes have no Telegraf Postgres credentials: ${missing[*]}")
|
||||||
|
FINAL_MESSAGE_QUEUE+=(" - Add them with sudo so-telegraf-cred add <minion_id>; the next soup will offer the switch.")
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n $UNATTENDED ]]; then
|
||||||
|
FINAL_MESSAGE_QUEUE+=("NOTE: InfluxDB will be removed in a future Security Onion release, and this grid still stores metrics in it (telegraf.output is $output).")
|
||||||
|
FINAL_MESSAGE_QUEUE+=(" - Setting telegraf.output to POSTGRES in Configuration switches the grid to Postgres and deletes InfluxDB and all its data.")
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "InfluxDB will be removed in a future Security Onion release. This grid stores its"
|
||||||
|
echo "metrics in InfluxDB (telegraf.output is $output)."
|
||||||
|
echo ""
|
||||||
|
echo "Every grid must move its metrics to Postgres before that release. Existing InfluxDB"
|
||||||
|
echo "metrics are not migrated."
|
||||||
|
echo ""
|
||||||
|
echo "Switching now points Telegraf at Postgres and removes InfluxDB, deleting all of its"
|
||||||
|
echo "data, during this upgrade. This cannot be undone, and switching back afterwards is"
|
||||||
|
echo "not supported. InfluxDB's alarm checks are deleted with it; the Postgres recommended"
|
||||||
|
echo "alarms can be added from the Grid page."
|
||||||
|
echo ""
|
||||||
|
read -rp "Switch metrics to Postgres now? [y/N]: " answer
|
||||||
|
if [[ "$answer" == [yY] ]]; then
|
||||||
|
INFLUX_SWITCH_ACCEPTED=1
|
||||||
|
else
|
||||||
|
echo "Keeping telegraf.output set to $output."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
influxdb_switch_apply() {
|
||||||
|
local mid
|
||||||
|
local -a failed=()
|
||||||
|
[[ -n $INFLUX_SWITCH_ACCEPTED ]] || return 0
|
||||||
|
if [[ -n $INFLUX_CREATE_CREDS ]]; then
|
||||||
|
echo "Creating Telegraf Postgres credentials for accepted minions."
|
||||||
|
for mid in $INFLUX_SWITCH_MINIONS; do
|
||||||
|
bash "$UPDATE_DIR/salt/manager/tools/sbin/so-telegraf-cred" add "$mid" || failed+=("$mid")
|
||||||
|
done
|
||||||
|
if (( ${#failed[@]} > 0 )); then
|
||||||
|
FINAL_MESSAGE_QUEUE+=("WARNING: Unable to create Telegraf Postgres credentials for these nodes, so the grid stays on its current metrics output: ${failed[*]}")
|
||||||
|
FINAL_MESSAGE_QUEUE+=(" - Once their credentials exist, set telegraf.output to POSTGRES in Configuration to switch.")
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "Setting telegraf.output to POSTGRES in $TELEGRAF_PILLAR."
|
||||||
|
if ! { mkdir -p "$(dirname "$TELEGRAF_PILLAR")" && touch "$TELEGRAF_PILLAR" &&
|
||||||
|
so-yaml.py replace "$TELEGRAF_PILLAR" telegraf.output POSTGRES; }; then
|
||||||
|
FINAL_MESSAGE_QUEUE+=("WARNING: Unable to set telegraf.output to POSTGRES in $TELEGRAF_PILLAR, so metrics stay in InfluxDB. Set it in Configuration to switch.")
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
chown socore:socore "$TELEGRAF_PILLAR" 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
|
influxdb_retire_check() {
|
||||||
|
[[ "$(so_telegraf_output 2>/dev/null)" == "POSTGRES" ]] || return 0
|
||||||
|
if influxdb_container_exists; then
|
||||||
|
FINAL_MESSAGE_QUEUE+=("NOTE: InfluxDB is still on this manager. The next highstate tries again to remove it and delete all its data.")
|
||||||
|
elif [[ -n $INFLUX_DELETE_ACCEPTED ]]; then
|
||||||
|
FINAL_MESSAGE_QUEUE+=("NOTE: This upgrade removed InfluxDB and deleted all its data, as accepted with --deletes-accepted.")
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
check_saltmaster_status() {
|
check_saltmaster_status() {
|
||||||
set +e
|
set +e
|
||||||
echo "Waiting on the Salt Master service to be ready."
|
echo "Waiting on the Salt Master service to be ready."
|
||||||
@@ -1249,6 +1430,18 @@ remove_auto_apply_batch_wait() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_soc_postgres_upgrade() {
|
||||||
|
local image
|
||||||
|
[[ "$(so_telegraf_output 2>/dev/null)" != "INFLUXDB" ]] || return 0
|
||||||
|
telegraf_creds_present "$MINIONID" || return 0
|
||||||
|
image=$(docker inspect --format '{{.Config.Image}}' so-soc 2>/dev/null) || image=
|
||||||
|
if [[ "$image" != *":$NEWVERSION" ]]; then
|
||||||
|
echo ""
|
||||||
|
echo "WARNING: SOC was not upgraded to $NEWVERSION because the Telegraf Postgres role setup failed. Fix Postgres, then run a highstate:"
|
||||||
|
echo " - sudo salt-call state.highstate"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
post_to_3.5.0() {
|
post_to_3.5.0() {
|
||||||
# Generate 9.4.10 elastic agent installers
|
# Generate 9.4.10 elastic agent installers
|
||||||
echo "Regenerating Elastic Agent Installers"
|
echo "Regenerating Elastic Agent Installers"
|
||||||
@@ -2164,6 +2357,10 @@ main() {
|
|||||||
check_cluster_health
|
check_cluster_health
|
||||||
check_fleet_server
|
check_fleet_server
|
||||||
|
|
||||||
|
if [[ "$is_hotfix" != "true" ]]; then
|
||||||
|
influxdb_switch_prompt
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Checking for Salt Master and Minion updates."
|
echo "Checking for Salt Master and Minion updates."
|
||||||
upgrade_check_salt
|
upgrade_check_salt
|
||||||
set -e
|
set -e
|
||||||
@@ -2253,6 +2450,7 @@ main() {
|
|||||||
echo "Running so-config-backup script."
|
echo "Running so-config-backup script."
|
||||||
/sbin/so-config-backup
|
/sbin/so-config-backup
|
||||||
fi
|
fi
|
||||||
|
influxdb_switch_apply
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Copying new Security Onion code from $UPDATE_DIR to $DEFAULT_SALT_DIR."
|
echo "Copying new Security Onion code from $UPDATE_DIR to $DEFAULT_SALT_DIR."
|
||||||
@@ -2330,7 +2528,7 @@ main() {
|
|||||||
fi
|
fi
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
highstate
|
highstate || { rc=$?; check_soc_postgres_upgrade; exit $rc; }
|
||||||
check_saltmaster_status
|
check_saltmaster_status
|
||||||
postupgrade_changes
|
postupgrade_changes
|
||||||
[[ $is_airgap -eq 0 ]] && unmount_update
|
[[ $is_airgap -eq 0 ]] && unmount_update
|
||||||
@@ -2404,6 +2602,8 @@ For more information, please see $DOC_BASE_URL/soup#distributed-deployments.
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
influxdb_retire_check
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$NOTIFYCUSTOMELASTICCONFIG" = true ] ; then
|
if [ "$NOTIFYCUSTOMELASTICCONFIG" = true ] ; then
|
||||||
@@ -2431,6 +2631,16 @@ fi
|
|||||||
echo "### soup has been served at $(date) ###"
|
echo "### soup has been served at $(date) ###"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
soup_args=()
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [[ "$arg" == "--deletes-accepted" ]]; then
|
||||||
|
DELETES_ACCEPTED=true
|
||||||
|
else
|
||||||
|
soup_args+=("$arg")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
set -- "${soup_args[@]}"
|
||||||
|
|
||||||
while getopts ":b:f:y" opt; do
|
while getopts ":b:f:y" opt; do
|
||||||
case ${opt} in
|
case ${opt} in
|
||||||
b )
|
b )
|
||||||
@@ -2454,7 +2664,7 @@ while getopts ":b:f:y" opt; do
|
|||||||
ISOLOC="$OPTARG"
|
ISOLOC="$OPTARG"
|
||||||
;;
|
;;
|
||||||
\? )
|
\? )
|
||||||
echo "Usage: soup [-b] [-y] [-f <iso location>]"
|
echo "Usage: soup [-b] [-y] [--deletes-accepted] [-f <iso location>]"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
: )
|
: )
|
||||||
|
|||||||
@@ -20,17 +20,11 @@ CRITICAL_AGENTS_FILE="/opt/so/conf/agents/critical-agents.txt"
|
|||||||
OFFLINE_THRESHOLD_HOURS={{ OFFLINE_THRESHOLD_HOURS }}
|
OFFLINE_THRESHOLD_HOURS={{ OFFLINE_THRESHOLD_HOURS }}
|
||||||
REALERT_THRESHOLD={{ REALERT_THRESHOLD }}
|
REALERT_THRESHOLD={{ REALERT_THRESHOLD }}
|
||||||
PAGE_SIZE="{{ PAGE_SIZE }}"
|
PAGE_SIZE="{{ PAGE_SIZE }}"
|
||||||
# Safety limit on pagination loops; Fleet page-based results are also capped at 10000 agents.
|
|
||||||
MAX_PAGES=100
|
|
||||||
|
|
||||||
log_message() {
|
log_message() {
|
||||||
local level="$1"
|
local level="$1"
|
||||||
local message="$2"
|
local message="$2"
|
||||||
echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ") [$level] $message" >&2
|
echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ") [$level] $message" >&2
|
||||||
# ERROR also goes to syslog: cron output is not monitored, and syslog is shipped to Elasticsearch.
|
|
||||||
if [ "$level" = "ERROR" ]; then
|
|
||||||
logger -t so-elastic-agent-monitor -p user.err -- "ERROR: $message" 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
matches_critical_pattern() {
|
matches_critical_pattern() {
|
||||||
@@ -141,70 +135,42 @@ main() {
|
|||||||
local page=1
|
local page=1
|
||||||
local total_agents=0
|
local total_agents=0
|
||||||
local processed_agents=0
|
local processed_agents=0
|
||||||
local agents_in_page=0
|
|
||||||
local agents=()
|
|
||||||
local current_timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
local current_timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
|
||||||
{%- if CUSTOM_KQUERY != None and CUSTOM_KQUERY | length > 0 %}
|
{%- if CUSTOM_KQUERY != None and CUSTOM_KQUERY | length > 0 %}
|
||||||
log_message "INFO" "Using custom kquery: {{ CUSTOM_KQUERY }}"
|
log_message "INFO" "Using custom kquery: {{ CUSTOM_KQUERY }}"
|
||||||
FLEET_QUERY="${FLEET_API}?kuery={{ CUSTOM_KQUERY | urlencode }}&perPage=${PAGE_SIZE}"
|
FLEET_QUERY="${FLEET_API}?kuery={{ CUSTOM_KQUERY | urlencode }}&perPage=${PAGE_SIZE}&page=${page}"
|
||||||
{%- else %}
|
{%- else %}
|
||||||
log_message "INFO" "Using default query (all offline or degraded agents)"
|
log_message "INFO" "Using default query (all offline or degraded agents)"
|
||||||
FLEET_QUERY="${FLEET_API}?kuery=status%3Aoffline%20OR%20status%3Adegraded&perPage=${PAGE_SIZE}"
|
FLEET_QUERY="${FLEET_API}?kuery=status%3Aoffline%20OR%20status%3Adegraded&perPage=${PAGE_SIZE}&page=${page}"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
if (( page * PAGE_SIZE > 10000 )); then
|
|
||||||
log_message "ERROR" "Fleet page-based results are limited to 10000 agents (page $page x page_size $PAGE_SIZE); $processed_agents of $total_agents agents were checked. Narrow the agents being monitored with custom_kquery under Administration -> Configuration -> manager -> agent_monitoring -> config (enable 'Show advanced settings')."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_message "INFO" "Fetching page $page (${PAGE_SIZE} agents per page)"
|
log_message "INFO" "Fetching page $page (${PAGE_SIZE} agents per page)"
|
||||||
|
|
||||||
if ! response_body=$(curl -K "$CURL_CONFIG" \
|
if ! response_body=$(curl -K "$CURL_CONFIG" \
|
||||||
-s --fail \
|
-s --fail \
|
||||||
"${FLEET_QUERY}&page=${page}" \
|
"$FLEET_QUERY" \
|
||||||
-H 'kbn-xsrf: true' 2>/dev/null); then
|
-H 'kbn-xsrf: true' 2>/dev/null); then
|
||||||
log_message "ERROR" "Failed to query Fleet API (page $page)"
|
log_message "ERROR" "Failed to query Fleet API (page $page)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Validate the response before parsing it so a bad response can never be
|
# pagination info
|
||||||
# mistaken for an empty page.
|
current_total=$(echo "$response_body" | jq -r '.total // 0')
|
||||||
if ! echo "$response_body" | jq -e 'type == "object"' >/dev/null 2>&1; then
|
current_page=$(echo "$response_body" | jq -r '.page // 1')
|
||||||
log_message "ERROR" "Malformed Fleet API response on page $page: not a valid JSON object"
|
agents_in_page=$(echo "$response_body" | jq -r '.list | length')
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! current_total=$(echo "$response_body" | jq -e '.total | select(type == "number" and . >= 0 and . == floor)' 2>/dev/null); then
|
# Update total
|
||||||
log_message "ERROR" "Malformed Fleet API response on page $page: missing or invalid total"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Fleet 9.x returns agents under "items"; older responses used "list".
|
|
||||||
if ! agents_json=$(echo "$response_body" | jq -c '(.items // .list) | if type == "array" then .[] else error("no agent array") end' 2>/dev/null); then
|
|
||||||
log_message "ERROR" "Malformed Fleet API response on page $page: missing or invalid agent collection (items/list)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use the latest page's total: agents changing status between pages
|
|
||||||
# (e.g. coming back online) shrink the offline/degraded result set.
|
|
||||||
total_agents="$current_total"
|
|
||||||
if [ "$page" -eq 1 ]; then
|
if [ "$page" -eq 1 ]; then
|
||||||
|
total_agents="$current_total"
|
||||||
log_message "INFO" "Found $total_agents total agents across all pages"
|
log_message "INFO" "Found $total_agents total agents across all pages"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Process agents from current page
|
log_message "INFO" "Processing page $current_page with $agents_in_page agents"
|
||||||
agents=()
|
|
||||||
agents_in_page=0
|
|
||||||
if [ -n "$agents_json" ]; then
|
|
||||||
while IFS= read -r agent; do
|
|
||||||
agents+=("$agent")
|
|
||||||
agents_in_page=$((agents_in_page + 1))
|
|
||||||
done <<< "$agents_json"
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_message "INFO" "Processing page $page with $agents_in_page agents"
|
# Process agents from current page
|
||||||
|
mapfile -t agents < <(echo "$response_body" | jq -c '.list[]')
|
||||||
|
|
||||||
for agent in "${agents[@]}"; do
|
for agent in "${agents[@]}"; do
|
||||||
# Grab agent details
|
# Grab agent details
|
||||||
@@ -268,20 +234,17 @@ main() {
|
|||||||
|
|
||||||
processed_agents=$((processed_agents + agents_in_page))
|
processed_agents=$((processed_agents + agents_in_page))
|
||||||
|
|
||||||
if [ "$processed_agents" -ge "$total_agents" ]; then
|
if [ "$agents_in_page" -eq 0 ] || [ "$processed_agents" -ge "$total_agents" ]; then
|
||||||
|
log_message "INFO" "Completed processing all pages. Total processed: $processed_agents agents"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$agents_in_page" -eq 0 ]; then
|
|
||||||
log_message "ERROR" "Incomplete agent scan: page $page was empty after $processed_agents of $total_agents agents"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
page=$((page + 1))
|
page=$((page + 1))
|
||||||
|
|
||||||
if [ "$page" -gt "$MAX_PAGES" ]; then
|
# Limit pagination loops incase of any issues. If agent count is high enough increase page_size in SOC manager.agent_monitoring.config.page_size
|
||||||
log_message "ERROR" "Reached maximum page limit ($MAX_PAGES) after $processed_agents of $total_agents agents. Issue with script or extremely large fleet deployment. Consider increasing page_size under Administration -> Configuration -> manager -> agent_monitoring -> config -> page_size (enable 'Show advanced settings')."
|
if [ "$page" -gt 100 ]; then
|
||||||
exit 1
|
log_message "ERROR" "Reached maximum page limit (100). Issue with script or extremely large fleet deployment. Consider increasing page_size in SOC -> manager.agent_monitoring.config.page_size"
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
{%- from 'vars/globals.map.jinja' import GLOBALS %}
|
{%- from 'vars/globals.map.jinja' import GLOBALS %}
|
||||||
{%- from 'docker/docker.map.jinja' import DOCKERMERGED %}
|
{%- from 'docker/docker.map.jinja' import DOCKERMERGED %}
|
||||||
{%- from 'nginx/map.jinja' import NGINXMERGED %}
|
{%- from 'nginx/map.jinja' import NGINXMERGED %}
|
||||||
|
{%- from 'telegraf/map.jinja' import INFLUX_RETIRED %}
|
||||||
{%- set role = grains.id.split('_') | last %}
|
{%- set role = grains.id.split('_') | last %}
|
||||||
{%- set influxpass = salt['pillar.get']('secrets:influx_pass') %}
|
|
||||||
{%- set influxauth = ('so:' + influxpass) | base64_encode %}
|
|
||||||
{%- set all_names = [GLOBALS.hostname, GLOBALS.url_base] + NGINXMERGED.ssl.alt_names %}
|
{%- set all_names = [GLOBALS.hostname, GLOBALS.url_base] + NGINXMERGED.ssl.alt_names %}
|
||||||
{%- set full_server_name = all_names | unique | join(' ') %}
|
{%- set full_server_name = all_names | unique | join(' ') %}
|
||||||
|
|
||||||
@@ -34,8 +33,6 @@ http {
|
|||||||
|
|
||||||
server_tokens off;
|
server_tokens off;
|
||||||
|
|
||||||
ssl_ecdh_curve X25519MLKEM768:SecP256r1MLKEM768:SecP384r1MLKEM1024/X25519:secp521r1:secp384r1;
|
|
||||||
|
|
||||||
include /etc/nginx/mime.types;
|
include /etc/nginx/mime.types;
|
||||||
default_type application/octet-stream;
|
default_type application/octet-stream;
|
||||||
|
|
||||||
@@ -86,6 +83,7 @@ http {
|
|||||||
ssl_session_cache shared:SSL:1m;
|
ssl_session_cache shared:SSL:1m;
|
||||||
ssl_session_timeout 10m;
|
ssl_session_timeout 10m;
|
||||||
ssl_ciphers TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256:TLS_RSA_WITH_AES_256_GCM_SHA384:TLS_RSA_WITH_AES_256_CCM:TLS_RSA_WITH_ARIA_256_GCM_SHA384:TLS_RSA_WITH_AES_128_GCM_SHA256:TLS_RSA_WITH_AES_128_CCM:TLS_RSA_WITH_ARIA_128_GCM_SHA256;
|
ssl_ciphers TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256:TLS_RSA_WITH_AES_256_GCM_SHA384:TLS_RSA_WITH_AES_256_CCM:TLS_RSA_WITH_ARIA_256_GCM_SHA384:TLS_RSA_WITH_AES_128_GCM_SHA256:TLS_RSA_WITH_AES_128_CCM:TLS_RSA_WITH_ARIA_128_GCM_SHA256;
|
||||||
|
ssl_ecdh_curve X25519:secp521r1:secp384r1;
|
||||||
ssl_prefer_server_ciphers on;
|
ssl_prefer_server_ciphers on;
|
||||||
ssl_protocols TLSv1.2 TLSv1.3;
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
}
|
}
|
||||||
@@ -112,6 +110,7 @@ http {
|
|||||||
ssl_session_cache shared:SSL:1m;
|
ssl_session_cache shared:SSL:1m;
|
||||||
ssl_session_timeout 10m;
|
ssl_session_timeout 10m;
|
||||||
ssl_ciphers TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256:TLS_RSA_WITH_AES_256_GCM_SHA384:TLS_RSA_WITH_AES_256_CCM:TLS_RSA_WITH_ARIA_256_GCM_SHA384:TLS_RSA_WITH_AES_128_GCM_SHA256:TLS_RSA_WITH_AES_128_CCM:TLS_RSA_WITH_ARIA_128_GCM_SHA256;
|
ssl_ciphers TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256:TLS_RSA_WITH_AES_256_GCM_SHA384:TLS_RSA_WITH_AES_256_CCM:TLS_RSA_WITH_ARIA_256_GCM_SHA384:TLS_RSA_WITH_AES_128_GCM_SHA256:TLS_RSA_WITH_AES_128_CCM:TLS_RSA_WITH_ARIA_128_GCM_SHA256;
|
||||||
|
ssl_ecdh_curve X25519:secp521r1:secp384r1;
|
||||||
ssl_prefer_server_ciphers on;
|
ssl_prefer_server_ciphers on;
|
||||||
ssl_protocols TLSv1.2 TLSv1.3;
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
location / {
|
location / {
|
||||||
@@ -145,6 +144,7 @@ http {
|
|||||||
ssl_session_cache shared:SSL:1m;
|
ssl_session_cache shared:SSL:1m;
|
||||||
ssl_session_timeout 10m;
|
ssl_session_timeout 10m;
|
||||||
ssl_ciphers TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256:TLS_RSA_WITH_AES_256_GCM_SHA384:TLS_RSA_WITH_AES_256_CCM:TLS_RSA_WITH_ARIA_256_GCM_SHA384:TLS_RSA_WITH_AES_128_GCM_SHA256:TLS_RSA_WITH_AES_128_CCM:TLS_RSA_WITH_ARIA_128_GCM_SHA256;
|
ssl_ciphers TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256:TLS_RSA_WITH_AES_256_GCM_SHA384:TLS_RSA_WITH_AES_256_CCM:TLS_RSA_WITH_ARIA_256_GCM_SHA384:TLS_RSA_WITH_AES_128_GCM_SHA256:TLS_RSA_WITH_AES_128_CCM:TLS_RSA_WITH_ARIA_128_GCM_SHA256;
|
||||||
|
ssl_ecdh_curve X25519:secp521r1:secp384r1;
|
||||||
ssl_prefer_server_ciphers on;
|
ssl_prefer_server_ciphers on;
|
||||||
ssl_protocols TLSv1.2 TLSv1.3;
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
|
||||||
@@ -309,6 +309,7 @@ http {
|
|||||||
autoindex_localtime on;
|
autoindex_localtime on;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{%- if not INFLUX_RETIRED %}
|
||||||
location /influxdb/ {
|
location /influxdb/ {
|
||||||
auth_request /auth/sessions/whoami;
|
auth_request /auth/sessions/whoami;
|
||||||
rewrite /influxdb/api/(.*) /api/$1 break;
|
rewrite /influxdb/api/(.*) /api/$1 break;
|
||||||
@@ -322,6 +323,7 @@ http {
|
|||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
proxy_cookie_path /api/ /influxdb/api/;
|
proxy_cookie_path /api/ /influxdb/api/;
|
||||||
}
|
}
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
location /app/dashboards/ {
|
location /app/dashboards/ {
|
||||||
auth_request /auth/sessions/whoami;
|
auth_request /auth/sessions/whoami;
|
||||||
|
|||||||
@@ -6,16 +6,12 @@
|
|||||||
{% from 'allowed_states.map.jinja' import allowed_states %}
|
{% from 'allowed_states.map.jinja' import allowed_states %}
|
||||||
{% if sls.split('.')[0] in allowed_states %}
|
{% if sls.split('.')[0] in allowed_states %}
|
||||||
{% from 'vars/globals.map.jinja' import GLOBALS %}
|
{% from 'vars/globals.map.jinja' import GLOBALS %}
|
||||||
{% from 'telegraf/map.jinja' import TELEGRAFMERGED %}
|
|
||||||
|
|
||||||
{# postgres.enabled declares the so-postgres container and postgres_wait_ready
|
{# postgres.enabled declares the so-postgres container and postgres_wait_ready
|
||||||
that the requires below reference. Salt de-duplicates the circular include. #}
|
that the requires below reference. Salt de-duplicates the circular include. #}
|
||||||
include:
|
include:
|
||||||
- postgres.enabled
|
- postgres.enabled
|
||||||
|
|
||||||
{% set TG_OUT = TELEGRAFMERGED.output | upper %}
|
|
||||||
{% if TG_OUT in ['POSTGRES', 'BOTH'] %}
|
|
||||||
|
|
||||||
# Ensure the shared Telegraf database exists. init-db.sh only runs on a
|
# Ensure the shared Telegraf database exists. init-db.sh only runs on a
|
||||||
# fresh data dir, so hosts upgraded onto an existing /nsm/postgres volume
|
# fresh data dir, so hosts upgraded onto an existing /nsm/postgres volume
|
||||||
# would otherwise never get so_telegraf.
|
# would otherwise never get so_telegraf.
|
||||||
@@ -70,8 +66,6 @@ postgres_telegraf_retention_reconcile:
|
|||||||
- cmd: postgres_telegraf_group_role
|
- cmd: postgres_telegraf_group_role
|
||||||
- file: postgres_sbin
|
- file: postgres_sbin
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
{{sls}}_state_not_allowed:
|
{{sls}}_state_not_allowed:
|
||||||
|
|||||||
@@ -232,10 +232,20 @@ suricata:
|
|||||||
- state: suricata
|
- state: suricata
|
||||||
tgt: 'G@role:so-eval or G@role:so-heavynode or G@role:so-import or G@role:so-sensor or G@role:so-standalone'
|
tgt: 'G@role:so-eval or G@role:so-heavynode or G@role:so-import or G@role:so-sensor or G@role:so-standalone'
|
||||||
|
|
||||||
# telegraf: universal.
|
# telegraf: universal, then the manager states that follow the output setting.
|
||||||
|
# They run after telegraf so InfluxDB is retired and SOC switches metrics
|
||||||
|
# modules only once the nodes already point at the new output.
|
||||||
telegraf:
|
telegraf:
|
||||||
- state: telegraf
|
- state: telegraf
|
||||||
tgt: '*'
|
tgt: '*'
|
||||||
|
- state: influxdb
|
||||||
|
tgt: 'G@role:so-eval or G@role:so-import or G@role:so-manager or G@role:so-managerhype or G@role:so-managersearch or G@role:so-standalone'
|
||||||
|
- state: nginx
|
||||||
|
tgt: 'G@role:so-eval or G@role:so-import or G@role:so-manager or G@role:so-managerhype or G@role:so-managersearch or G@role:so-standalone'
|
||||||
|
- state: firewall
|
||||||
|
tgt: 'G@role:so-eval or G@role:so-import or G@role:so-manager or G@role:so-managerhype or G@role:so-managersearch or G@role:so-standalone'
|
||||||
|
- state: soc
|
||||||
|
tgt: 'G@role:so-eval or G@role:so-import or G@role:so-manager or G@role:so-managerhype or G@role:so-managersearch or G@role:so-standalone'
|
||||||
|
|
||||||
# versionlock: universal (top-of-file '*' branch in salt/top.sls).
|
# versionlock: universal (top-of-file '*' branch in salt/top.sls).
|
||||||
versionlock:
|
versionlock:
|
||||||
|
|||||||
@@ -5,9 +5,14 @@
|
|||||||
|
|
||||||
{% from 'allowed_states.map.jinja' import allowed_states %}
|
{% from 'allowed_states.map.jinja' import allowed_states %}
|
||||||
{% if sls.split('.')[0] in allowed_states %}
|
{% if sls.split('.')[0] in allowed_states %}
|
||||||
|
{% from 'soc/merged.map.jinja' import SOCMERGED %}
|
||||||
|
{% set use_pg_metrics = 'postgresmetrics' in SOCMERGED.config.server.modules %}
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- manager.sync_es_users
|
- manager.sync_es_users
|
||||||
|
{% if use_pg_metrics %}
|
||||||
|
- postgres.telegraf_users
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
sigmarepodir:
|
sigmarepodir:
|
||||||
file.directory:
|
file.directory:
|
||||||
@@ -77,6 +82,10 @@ socconfig:
|
|||||||
- mode: 600
|
- mode: 600
|
||||||
- template: jinja
|
- template: jinja
|
||||||
- show_changes: False
|
- show_changes: False
|
||||||
|
{% if use_pg_metrics %}
|
||||||
|
- require:
|
||||||
|
- sls: postgres.telegraf_users
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
socmotd:
|
socmotd:
|
||||||
file.managed:
|
file.managed:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
{% from 'soc/defaults.map.jinja' import SOCDEFAULTS with context %}
|
{% from 'soc/defaults.map.jinja' import SOCDEFAULTS with context %}
|
||||||
{% from 'elasticsearch/config.map.jinja' import ELASTICSEARCH_NODES %}
|
{% from 'elasticsearch/config.map.jinja' import ELASTICSEARCH_NODES %}
|
||||||
{% from 'manager/map.jinja' import MANAGERMERGED %}
|
{% from 'manager/map.jinja' import MANAGERMERGED %}
|
||||||
{% from 'telegraf/map.jinja' import TELEGRAFMERGED %}
|
{% from 'telegraf/map.jinja' import PG_METRICS_READY %}
|
||||||
{% from 'elastalert/map.jinja' import ELASTALERTMERGED %}
|
{% from 'elastalert/map.jinja' import ELASTALERTMERGED %}
|
||||||
{%- set PG_ENTRY = salt['pillar.get']('telegraf:postgres_creds:' ~ grains.id, {}) %}
|
{%- set PG_ENTRY = salt['pillar.get']('telegraf:postgres_creds:' ~ grains.id, {}) %}
|
||||||
{%- set PG_USER = PG_ENTRY.get('user', '') %}
|
{%- set PG_USER = PG_ENTRY.get('user', '') %}
|
||||||
@@ -129,7 +129,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{# Define the postgresmetrics module if telegraf is setup to only use Postgres #}
|
{# Define the postgresmetrics module if telegraf is setup to only use Postgres #}
|
||||||
{% if TELEGRAFMERGED.output != 'INFLUXDB' and PG_USER and PG_PASS %}
|
{% if PG_METRICS_READY %}
|
||||||
{% do SOCMERGED.config.server.modules.update({
|
{% do SOCMERGED.config.server.modules.update({
|
||||||
'postgresmetrics': {
|
'postgresmetrics': {
|
||||||
'database': 'so_telegraf',
|
'database': 'so_telegraf',
|
||||||
|
|||||||
@@ -158,6 +158,21 @@ tgraf_sbin_jinja:
|
|||||||
- defaults:
|
- defaults:
|
||||||
CONTAINER_STATS: {{ TELEGRAFMERGED.container_stats }}
|
CONTAINER_STATS: {{ TELEGRAFMERGED.container_stats }}
|
||||||
|
|
||||||
|
{% set tg_output = TELEGRAFMERGED.output | upper %}
|
||||||
|
{% set pg_creds = salt['pillar.get']('telegraf:postgres_creds:' ~ GLOBALS.minion_id, {}) %}
|
||||||
|
{% set pg_creds_missing = tg_output in ['POSTGRES', 'BOTH'] and not (pg_creds.get('user') and pg_creds.get('pass')) %}
|
||||||
|
{% if pg_creds_missing %}
|
||||||
|
{% set pg_creds_text = 'Telegraf Postgres credentials for ' ~ GLOBALS.minion_id ~ ' are missing from the pillar. On the manager, run so-telegraf-cred add ' ~ GLOBALS.minion_id ~ ', then run a highstate on this node.' %}
|
||||||
|
telegraf_postgres_creds_missing:
|
||||||
|
{% if tg_output == 'POSTGRES' %}
|
||||||
|
test.fail_without_changes:
|
||||||
|
- comment: {{ pg_creds_text | tojson }}
|
||||||
|
{% else %}
|
||||||
|
test.show_notification:
|
||||||
|
- text: {{ pg_creds_text | tojson }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
tgrafconf:
|
tgrafconf:
|
||||||
file.managed:
|
file.managed:
|
||||||
- name: /opt/so/conf/telegraf/etc/telegraf.conf
|
- name: /opt/so/conf/telegraf/etc/telegraf.conf
|
||||||
@@ -171,6 +186,10 @@ tgrafconf:
|
|||||||
GLOBALS: {{ GLOBALS }}
|
GLOBALS: {{ GLOBALS }}
|
||||||
TELEGRAFMERGED: {{ TELEGRAFMERGED }}
|
TELEGRAFMERGED: {{ TELEGRAFMERGED }}
|
||||||
LOGSTASH_MERGED: {{ LOGSTASH_MERGED }}
|
LOGSTASH_MERGED: {{ LOGSTASH_MERGED }}
|
||||||
|
{% if pg_creds_missing %}
|
||||||
|
- require:
|
||||||
|
- test: telegraf_postgres_creds_missing
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
# this file will be read by telegraf to send node details (management interface, monitor interface, etc)
|
# this file will be read by telegraf to send node details (management interface, monitor interface, etc)
|
||||||
# into influx
|
# into influx
|
||||||
|
|||||||
@@ -6,6 +6,13 @@
|
|||||||
{% from 'vars/globals.map.jinja' import GLOBALS %}
|
{% from 'vars/globals.map.jinja' import GLOBALS %}
|
||||||
{% import_yaml 'telegraf/defaults.yaml' as TELEGRAFDEFAULTS %}
|
{% import_yaml 'telegraf/defaults.yaml' as TELEGRAFDEFAULTS %}
|
||||||
{% set TELEGRAFMERGED = salt['pillar.get']('telegraf', TELEGRAFDEFAULTS.telegraf, merge=True) %}
|
{% set TELEGRAFMERGED = salt['pillar.get']('telegraf', TELEGRAFDEFAULTS.telegraf, merge=True) %}
|
||||||
|
{% set TG_OUTPUT = TELEGRAFMERGED.output | upper %}
|
||||||
|
{% set TG_PG_ENTRY = salt['pillar.get']('telegraf:postgres_creds:' ~ GLOBALS.minion_id, {}) %}
|
||||||
|
{% set PG_METRICS_READY = false %}
|
||||||
|
{% if TG_OUTPUT != 'INFLUXDB' and TG_PG_ENTRY.get('user') and TG_PG_ENTRY.get('pass') %}
|
||||||
|
{% set PG_METRICS_READY = true %}
|
||||||
|
{% endif %}
|
||||||
|
{% set INFLUX_RETIRED = TG_OUTPUT == 'POSTGRES' and PG_METRICS_READY %}
|
||||||
|
|
||||||
{% if GLOBALS.role in ['so-eval', 'so-standalone', 'so-sensor', 'so-heavynode'] %}
|
{% if GLOBALS.role in ['so-eval', 'so-standalone', 'so-sensor', 'so-heavynode'] %}
|
||||||
{% from 'zeek/config.map.jinja' import ZEEKMERGED %}
|
{% from 'zeek/config.map.jinja' import ZEEKMERGED %}
|
||||||
@@ -22,3 +29,10 @@
|
|||||||
{% do TELEGRAFMERGED.scripts[GLOBALS.role.split('-')[1]].remove('redis.sh') %}
|
{% do TELEGRAFMERGED.scripts[GLOBALS.role.split('-')[1]].remove('redis.sh') %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if INFLUX_RETIRED %}
|
||||||
|
{% set role_scripts = TELEGRAFMERGED.scripts.get(GLOBALS.role.split('-')[1], []) %}
|
||||||
|
{% if 'influxdbsize.sh' in role_scripts %}
|
||||||
|
{% do role_scripts.remove('influxdbsize.sh') %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
@@ -5,14 +5,14 @@ telegraf:
|
|||||||
advanced: True
|
advanced: True
|
||||||
helpLink: influxdb
|
helpLink: influxdb
|
||||||
output:
|
output:
|
||||||
description: Selects the backend(s) Telegraf writes metrics to. INFLUXDB keeps the current behavior; POSTGRES writes to the grid's Postgres instance; BOTH dual-writes for migration validation. When set to BOTH, the grid screen's metrics are pulled from Postgres, and the InfluxDB tool link remains visible. When set to POSTGRES, the InfluxDB tool link is removed.
|
description: Selects the backend(s) Telegraf writes metrics to. INFLUXDB keeps the current behavior; POSTGRES writes to the grid's Postgres instance; BOTH dual-writes for migration validation. When set to BOTH, the grid screen's metrics are pulled from Postgres, and the InfluxDB tool link remains visible. When set to POSTGRES, the InfluxDB tool link is removed. WARNING - Choosing POSTGRES removes InfluxDB from the manager and permanently deletes all of its data; this cannot be undone. Switching back to INFLUXDB or BOTH afterwards is not supported, because InfluxDB would start again with no data. BOTH keeps InfluxDB running. InfluxDB will be removed in a future release, so grids should move to POSTGRES.
|
||||||
options:
|
options:
|
||||||
- INFLUXDB
|
- INFLUXDB
|
||||||
- POSTGRES
|
- POSTGRES
|
||||||
- BOTH
|
- BOTH
|
||||||
global: True
|
global: True
|
||||||
advanced: True
|
advanced: True
|
||||||
helpLink: influxdb
|
helpLink: postgresql
|
||||||
config:
|
config:
|
||||||
interval:
|
interval:
|
||||||
description: Data collection interval.
|
description: Data collection interval.
|
||||||
|
|||||||
Reference in new issue
Block a user