Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Support Logging to Coralogix #243

Closed
trieloff opened this issue Apr 17, 2020 · 2 comments
Closed

Support Logging to Coralogix #243

trieloff opened this issue Apr 17, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@trieloff
Copy link
Contributor

If the user is providing a CORALOGIX_KEY and a coralogixApplication parameter, then set up a new HTTPS logging endpoint named "Coralogix" with following settings:

{
  "timestamp": %{time.start.msec}V, 
  "applicationName": "trieloff", 
  "subsystemName": "%{req.service_id}V", 
  "severity": %{if(resp.status<400, "3", "")}V%{if(resp.status>=400 && resp.status<500, "4", "")}V%{if(resp.status>=500, "5", "")}V, 
  "json": { 
    "ow": {
      "activationId": "%{req.http.x-openwhisk-activation-id}V"
    },
    "cdn": {
      "url": "https://%{req.http.host}V%{cstr_escape(req.url)}V",
      "host": "%{req.http.host}V",
      "service_id":"%{req.service_id}V",
      "version": "%{req.http.X-Version}V",
      "time": {
        "start": "%{begin:%Y-%m-%dT%H:%M:%S%Z}t",
        "end": "%{end:%Y-%m-%dT%H:%M:%S%Z}t",
        "elapsed": %D
      },
      "client": {
        "name": "%{client.as.name}V",
        "number": "%{client.as.number}V",
        "connection_speed": "%{client.geo.conn_speed}V",
        "ip": "%{regsuball(req.http.X-Forwarded-For, "((\\d+)\\.(\\d+)\\.(\\d+)\\.)(\\d+)", "\\1xxx")}V"
      },
      "request": {
        "id": "%{req.http.X-CDN-Request-ID}V",
        "method": "%m",
        "protocol": "%H",
        "h2": %{if(fastly_info.is_h2, "true", "false")}V,
        "h2_push": %{if(fastly_info.h2.is_push, "true", "false")}V,
        "is_ipv6": %{if(req.is_ipv6, "true", "false")}V,
        "h2_stream_id": "%{fastly_info.h2.stream_id}V",
        "url":"%{cstr_escape(req.url)}V",
        "referer": "%{Referer}i",
        "user_agent": "%{User-Agent}i",
        "accept_content": "%{Accept}i",
        "accept_language": "%{Accept-Language}i",
        "accept_encoding": "%{Accept-Encoding}i",
        "accept_charset": "%{Accept-Charset}i",
        "connection": "%{Connection}i",
        "dnt": "%{DNT}i",
        "forwarded": "%{Forwarded}i",
        "via": "%{Via}i",
        "cache_control": "%{Cache-Control}i",
        "x_requested_with": "%{X-Requested-With}i",
        "header_size": %{req.header_bytes_read}V,
        "body_size": %{req.body_bytes_read}V
      },
      "origin": {
        "host": "%v"
      },
      "response": {
        "status":"%s",
        "content_type":"%{Content-Type}o",
        "age":"%{Age}o",
        "cache_control":"%{Cache-Control}o",
        "expires":"%{Expires}o",
        "last_modified":"%{Last-Modified}o",
        "tsv":"%{TSV}o",
        "header_size": %{resp.header_bytes_written}V,
        "body_size": %B
      },
      "edge": {
        "cache_status":"%{regsub(fastly_info.state, "^(HIT-(SYNTH)|(HITPASS|HIT|MISS|PASS|ERROR|PIPE)).*", "\\2\\3")}V",
        "is_cacheable":%{if(fastly_info.state ~"^(HIT|MISS)$", "true", "false")}V,
        "datacenter":"%{server.datacenter}V",
        "ip":"%A"
      },
      "socket": {
        "cwnd": %{client.socket.cwnd}V,
        "nexthop": "%{client.socket.nexthop}V",
        "tcpi_rcv_mss": %{client.socket.tcpi_rcv_mss}V,
        "tcpi_snd_mss": %{client.socket.tcpi_snd_mss}V,
        "tcpi_rtt": %{client.socket.tcpi_rtt}V,
        "tcpi_rttvar": %{client.socket.tcpi_rttvar}V,
        "tcpi_rcv_rtt": %{client.socket.tcpi_rcv_rtt}V,
        "tcpi_rcv_space": %{client.socket.tcpi_rcv_space}V,
        "tcpi_last_data_sent": %{client.socket.tcpi_last_data_sent}V,
        "tcpi_total_retrans": %{client.socket.tcpi_total_retrans}V,
        "tcpi_delta_retrans": %{client.socket.tcpi_delta_retrans}V,
        "ploss": %{client.socket.ploss}V
      }
    }
  }
}

Note: the HTTP logging endpoint might not be enabled for a service config. In this case, the entire transaction should fail, even if Google logs have been set up successfully.

@trieloff
Copy link
Contributor Author

Requires adobe/fastly-native-promises#205

@trieloff
Copy link
Contributor Author

Depends on adobe/fastly-native-promises#208

@trieloff trieloff self-assigned this Apr 24, 2020
trieloff added a commit that referenced this issue Apr 24, 2020
@trieloff trieloff closed this as completed May 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant