Configuring Flex Gateway Logs for Third-Party Services
Anypoint Flex Gateway enables you to configure log output for consumption by third-party services. Logs can be delivered to any supported Fluent Bit v1.8 output. You configure log output via a custom YAML file.
The following example demonstrates how to redirect Flex Gateway logs to Splunk.
Before You Begin
Before configuring Flex Gateway log output for Splunk, complete the following tasks:
Additionally, ensure that you have:
-
A running Splunk service. You can test Splunk by setting up a free Splunk Cloud trial.
-
Added an HTTP Event Collector (HEC) data input to the Cloud or Enterprise Splunk service. See the Splunk documentation about how to add a data input, and how to create an HEC token.
Configure Log Output for Flex Gateway as a Linux Service
-
Create a YAML configuration file in the Flex Gateway configuration directory:
sudo touch /usr/local/share/mulesoft/flex-gateway/conf.d/logs-splunk-config.yaml
-
Update the file with your Splunk configuration details. For example:
sudo vi /usr/local/share/mulesoft/flex-gateway/conf.d/logs-splunk-config.yaml
The following
Configuration
resource defines Splunk output:apiVersion: gateway.mulesoft.com/v1alpha1 kind: Configuration metadata: name: splunk-config spec: logging: outputs: - name: splunk type: splunk parameters: host: <instance-name>.splunkcloud.com port: "8088" splunk_token: <Splunk's HEC token> tls: "on" tls.verify: "off" runtimeLogs: logLevel: info outputs: [splunk] accessLogs: outputs: [splunk]
Splunk will be begin ingesting logs soon after applying this resource. If no events appear in the Splunk dashboard, inspect the Flex Gateway flex-gateway-fluentbit
logs to determine if there are configuration errors.
Configure Log Output for Flex Gateway in a Docker Container
If you have already added a volume for a folder with your Flex Gateway configuration files, go to the last step. |
-
Stop your Flex Gateway and any replicas, using Ctrl+C.
-
Create a folder in the directory with your Flex Gateway configuration files and name it
app
. -
Restart your Flex Gateway with an additional volume for the new
app
directory:docker run --rm \ -v <absolute-path-to-directory-with-gateway-files>/:/usr/local/share/mulesoft/flex-gateway/conf.d \ -p 8080:8080 \ mulesoft/flex-gateway
Specify an optional name you want to assign to your Flex Replica by including the following: -e FLEX_NAME=<name-for-flex-replica> \
.The following
Configuration
resource defines Splunk output:apiVersion: gateway.mulesoft.com/v1alpha1 kind: Configuration metadata: name: splunk-config spec: logging: outputs: - name: splunk type: splunk parameters: host: <instance-name>.splunkcloud.com port: "8088" splunk_token: <Splunk's HEC token> tls: "on" tls.verify: "off" runtimeLogs: logLevel: info outputs: [splunk] accessLogs: outputs: [splunk]
Splunk will be begin ingesting logs soon after applying this resource. If no events appear in the Splunk dashboard, inspect the Flex Gateway flex-gateway-fluentbit
logs to determine if there are configuration errors.
Configure Log Output for Flex Gateway as a Kubernetes Ingress Controller
To configure shared storage for Flex Gateway, create a new resource using a YAML configuration file with your Splunk details.
The following Configuration
resource defines Splunk output:
apiVersion: gateway.mulesoft.com/v1alpha1
kind: Configuration
metadata:
name: splunk-config
spec:
logging:
outputs:
- name: splunk
type: splunk
parameters:
host: <instance-name>.splunkcloud.com
port: "8088"
splunk_token: <Splunk's HEC token>
tls: "on"
tls.verify: "off"
runtimeLogs:
logLevel: info
outputs: [splunk]
accessLogs:
outputs: [splunk]
Splunk will be begin ingesting logs soon after applying this resource. If no events appear in the Splunk dashboard, inspect the Flex Gateway flex-gateway-fluentbit
logs to determine if there are configuration errors.