get-cloudflare-logs

by anapsix

Helm chartv0.6.0App 0.6.0Verified publisher

Helm chart to retrieve Cloudflare Logs via LogPull API

About this chart

Feron / Get-Cloudflare-Logs Helm chart

NOTE: tested with Helm 3

Installing the Chart

Pre-create namespace you are planning on installing this chart into.

To install the chart with the release name my-release (i.e. ${CF_ZONE_NAME}):

helm install my-release \
  --namespace=get-cloudflare-logs \
  --set config.cloudflare.sampleRate="0.01" \
  --set config.cloudflare.zoneId="${CF_ZONE_ID}" \
  --set config.cloudflare.authEmail="${CF_AUTH_EMAIL}" \
  --set config.cloudflare.authKey="${CF_AUTH_KEY}" \
  --set config.elasticsearch.host="${ES_HOST}" \
  --set config.elasticsearch.username="${ES_USERNAME}" \
  --set config.elasticsearch.password="${ES_PASSWORD}" \
  --set config.elasticsearch.index.name="cloudflare-${CF_ZONE_NAME}" \
  --set config.elasticsearch.index.template.shards=5 \
  --set config.elasticsearch.index.template.replicas=0 \
  --set config.elasticsearch.index.template.refreshInterval=30s \
  .

Uninstalling the Chart

To uninstall/delete the my-release deployment:

$ helm delete my-release

Configuration

ParameterDescriptionDefault
image.pullPolicyImage pull policyAlways
image.repositoryImage repositorydocker.io/anapsix/get-cloudflare-logs
image.tagImage tag0.6.0 (same as .Chart.AppVersion)
image.pullSecretsSpecify image pull secrets[]
terminationGracePeriodSecondsTermination grace period (in seconds)15
revisionHistoryLimitHow many old ReplicaSets for this Deployment you want to retain10
affinityNode/pod affinities{}
nodeSelectorNode labels for pod assignment{}
resourcesPod resource requests & limits{}
tolerationsList of node taints to tolerate[]
config.cloudflare.sampleRateCF logs sample rate (0.01 = 1%)0.01
config.cloudflare.zoneIdCF Zone ID to pull logs for51e241f08e014feb95d1b2760228d12a (fake)
config.cloudflare.authEmailCF Auth Email[email protected] (fake)
config.cloudflare.authKeyCF Auth Key51e241f08e014feb95d1b2760228d12a2df50 (fake)
config.elasticsearch.hostElasticsearch host URLhttp://elasticsearch:9200
config.elasticsearch.usernameElasticsearch connection usernamenil
config.elasticsearch.passwordElasticsearch connection passwordnil
config.elasticsearch.index.nameElasticsearch dst indexcloudflare-access
config.elasticsearch.index.template.shardsElasticsearch dst index shards5
config.elasticsearch.index.template.replicasElasticsearch dst index replicas0
config.elasticsearch.index.template.refreshIntervalElasticsearch dst index refresh interval10s
config.elasticsearch.ilm.enabledEnables ILM usetrue
config.elasticsearch.ilm.policyYAMLSpecifies policy via YAMLsee values.yaml
config.elasticsearch.ilm.policyJSONSpecifies policy via literal JSONsee values.yaml
config.elasticsearch.ilm.policyFileSpecifies a file on local filesystem to use as ILM policyfiles/ilm-default-policy.json
config.elasticsearch.pipeline.enabledEnables Ingest Pipelinetrue (at the moment, has no effect)
config.elasticsearch.pipeline.defaultEnables use of default Ingest Pipelinetrue

Advanced Configuration

ILM Policy

By default, ILM policy setup is enabled, and policy defined with config.elasticsearch.ilm.policyYAML (same as one included in Docker image) will be used. To customize ILM policy, change config.elasticsearch.ilm.policyYAML.

ILM policy is stored as ConfigMap, and passed to the pods via read-only mount. It is mounted under /opt/extra-config/ilm-policy.json inside the pod.

ILM policy can be defined using any of the following attributes, listed in the order of precedence.

  • config.elasticsearch.ilm.policyYAML - inline, convenient for tweaking individual phases
  • config.elasticsearch.ilm.policyJSON - inline, convenient when copying from ES
  • config.elasticsearch.ilm.policyFile - from local file, convenient when copying from ES

If policyYAML is unset, or evaluates to false, policyJSON will be used. If both policyYAML, and policyJSON are unset, or evaluate to false, policyFile will be used

Read more about ILM and ILM policy in Elasticsearch docs.

Ingest Pipeline

By default, Ingest Pipeline included in Docker image is created, and enabled as "default pipeline". Read more about Pipelines and pipeline processors in Elasticsearch docs.

Default pipeline is configured with following processors:

  • user_agent - to process cloudflare.ClientRequestUserAgent
  • geoip - to process cloudflare.ClientIP

Deploy get-cloudflare-logs with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has get-cloudflare-logs on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartget-cloudflare-logs is pinned at v0.6.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply