apiVersion: v1
kind: ConfigMap
metadata:
  name: telegraf-configmap
data:
  telegraf.conf: |
    # Global Agent Configuration
    [agent]
      hostname = "simple-website-monitor"
      flush_interval = "30s"
      interval = "30s"

    # Input Plugins
    # Copied from: https://github.com/influxdata/telegraf/tree/master/plugins/inputs/http_response

    # HTTP/HTTPS request given an address a method and a timeout
    [[inputs.http_response]]
      ## address is Deprecated in 1.12, use 'urls'

      ## List of urls to query.
      urls = {{ .Values.swm.urls }}

      ## Set http_proxy (telegraf uses the system wide proxy settings if it's is not set)
      # http_proxy = "http://localhost:8888"

      ## Set response_timeout (default 5 seconds)
      # response_timeout = "5s"

      ## HTTP Request Method
      # method = "GET"

      ## Whether to follow redirects from the server (defaults to false)
      # follow_redirects = false
      follow_redirects = true

      ## Optional file with Bearer token
      ## file content is added as an Authorization header
      # bearer_token = "/path/to/file"

      ## Optional HTTP Basic Auth Credentials
      # username = "username"
      # password = "pa$$word"

      ## Optional HTTP Request Body
      # body = '''
      # {'fake':'data'}
      # '''

      ## Optional name of the field that will contain the body of the response.
      ## By default it is set to an empty String indicating that the body's content won't be added
      # response_body_field = ''

      ## Maximum allowed HTTP response body size in bytes.
      ## 0 means to use the default of 32MiB.
      ## If the response body size exceeds this limit a "body_read_error" will be raised
      # response_body_max_size = "32MiB"

      ## Optional substring or regex match in body of the response (case sensitive)
      # response_string_match = "\"service_status\": \"up\""
      # response_string_match = "ok"
      # response_string_match = "\".*_status\".?:.?\"up\""

      ## Expected response status code.
      ## The status code of the response is compared to this value. If they match, the field
      ## "response_status_code_match" will be 1, otherwise it will be 0. If the
      ## expected status code is 0, the check is disabled and the field won't be added.
      # response_status_code = 0

      ## Optional TLS Config
      # tls_ca = "/etc/telegraf/ca.pem"
      # tls_cert = "/etc/telegraf/cert.pem"
      # tls_key = "/etc/telegraf/key.pem"
      ## Use TLS but skip chain & host verification
      # insecure_skip_verify = false
      insecure_skip_verify = true
      ## Use the given name as the SNI server name on each URL
      # tls_server_name = ""

      ## HTTP Request Headers (all values must be strings)
      # [inputs.http_response.headers]
      #   Host = "github.com"

      ## Optional setting to map response http headers into tags
      ## If the http header is not present on the request, no corresponding tag will be added
      ## If multiple instances of the http header are present, only the first value will be used
      # http_header_tags = {"HTTP_HEADER" = "TAG_NAME"}

      ## Interface to use when dialing an address
      # interface = "eth0"

        # Output Plugin InfluxDB
    [[outputs.influxdb]]
      database = {{ .Values.swmDb.influxDbName | quote }}
      urls = [ {{ .Values.swmDb.influxDbUrl | quote }} ]
      username = {{ .Values.swmDb.influxDbUser | quote }}
      password = {{ .Values.swmDb.influxDbPW | quote }}
