Skip to content

Commit 0d8ad7f

Browse files
committed
Fastly: configure logs streaming for dl.k8s.io
Switch from BigQuery to Datadog for logs streaming Signed-off-by: Arnaud Meukam <ameukam@gmail.com>
1 parent 94d8b8b commit 0d8ad7f

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

infra/fastly/terraform/dl.k8s.io/data.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
data "google_secret_manager_secret_version_access" "datadog_api_key" {
18+
secret = "datadog_fastly_logs_streaming"
19+
project = "k8s-infra-releases-prod"
20+
}
21+
1722
data "google_secret_manager_secret_version_access" "gcs_reader_access_key" {
1823
secret = "fastly_reader_sa_access_key"
1924
project = "k8s-infra-releases-prod"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "ddsource": "fastly", "ddtags": "app:${dd_app},env:${dd_env}", "service": "${service_name}", "date": "%%{begin:%Y-%m-%dT%H:%M:%S%Z}t", "time_start": "%%{begin:%Y-%m-%dT%H:%M:%S%Z}t", "time_end": "%%{end:%Y-%m-%dT%H:%M:%S%Z}t", "http": { "request_time_ms": %D, "method": "%m", "url": "%%{json.escape(req.url)}V", "useragent": "%%{User-Agent}i", "referer": "%%{Referer}i", "protocol": "%H", "request_x_forwarded_for": "%%{X-Forwarded-For}i", "status_code": "%s" }, "network": { "client": { "ip": "%h", "name": "%%{client.as.name}V", "number": "%%{client.as.number}V", "connection_speed": "%%{client.geo.conn_speed}V" }, "destination": { "ip": "%A" }, "geoip": { "geo_city": "%%{client.geo.city.utf8}V", "geo_country_code": "%%{client.geo.country_code}V", "geo_continent_code": "%%{client.geo.continent_code}V", "geo_region": "%%{client.geo.region}V" }, "bytes_written": %B, "bytes_read": %%{req.body_bytes_read}V }, "host": "%%{if(req.http.Fastly-Orig-Host, req.http.Fastly-Orig-Host, req.http.Host)}V", "origin_host": "%v", "is_ipv6": %%{if(req.is_ipv6, "true", "false")}V, "is_tls": %%{if(req.is_ssl, "true", "false")}V, "tls_client_protocol": "%%{json.escape(tls.client.protocol)}V", "tls_client_servername": "%%{json.escape(tls.client.servername)}V", "tls_client_cipher": "%%{json.escape(tls.client.cipher)}V", "tls_client_cipher_sha": "%%{json.escape(tls.client.ciphers_sha)}V", "tls_client_tlsexts_sha": "%%{json.escape(tls.client.tlsexts_sha)}V", "is_h2": %%{if(fastly_info.is_h2, "true", "false")}V, "is_h2_push": %%{if(fastly_info.h2.is_push, "true", "false")}V, "h2_stream_id": "%%{fastly_info.h2.stream_id}V", "request_accept_content": "%%{Accept}i", "request_accept_language": "%%{Accept-Language}i", "request_accept_encoding": "%%{Accept-Encoding}i", "request_accept_charset": "%%{Accept-Charset}i", "request_connection": "%%{Connection}i", "request_dnt": "%%{DNT}i", "request_forwarded": "%%{Forwarded}i", "request_via": "%%{Via}i", "request_cache_control": "%%{Cache-Control}i", "request_x_requested_with": "%%{X-Requested-With}i", "request_x_att_device_id": "%%{X-ATT-Device-Id}i", "content_type": "%%{Content-Type}o", "is_cacheable": %%{if(fastly_info.state~"^(HIT|MISS)$", "true","false")}V, "response_age": "%%{Age}o", "response_cache_control": "%%{Cache-Control}o", "response_expires": "%%{Expires}o", "response_last_modified": "%%{Last-Modified}o", "response_tsv": "%%{TSV}o", "server_datacenter": "%%{server.datacenter}V", "req_header_size": %%{req.header_bytes_read}V, "resp_header_size": %%{resp.header_bytes_written}V, "socket_cwnd": %%{client.socket.cwnd}V, "socket_nexthop": "%%{client.socket.nexthop}V", "socket_tcpi_rcv_mss": %%{client.socket.tcpi_rcv_mss}V, "socket_tcpi_snd_mss": %%{client.socket.tcpi_snd_mss}V, "socket_tcpi_rtt": %%{client.socket.tcpi_rtt}V, "socket_tcpi_rttvar": %%{client.socket.tcpi_rttvar}V, "socket_tcpi_rcv_rtt": %%{client.socket.tcpi_rcv_rtt}V, "socket_tcpi_rcv_space": %%{client.socket.tcpi_rcv_space}V, "socket_tcpi_last_data_sent": %%{client.socket.tcpi_last_data_sent}V, "socket_tcpi_total_retrans": %%{client.socket.tcpi_total_retrans}V, "socket_tcpi_delta_retrans": %%{client.socket.tcpi_delta_retrans}V, "socket_ploss": %%{client.socket.ploss}V }

infra/fastly/terraform/dl.k8s.io/services.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ resource "fastly_service_vcl" "files" {
6565
window = 4
6666
} */
6767

68-
logging_bigquery {
69-
dataset = "fastly_bigquery_cdn_dl_k8s_io"
70-
project_id = "k8s-infra-public-pii"
71-
name = "BigQuery logging"
72-
table = "fastly_bigquery_cdn_dl_k8s_io_logs"
73-
account_name = "fastly-bigquery-logging-sa"
74-
email = "fastly-logging@datalog-bulleit-9e86.iam.gserviceaccount.com"
75-
76-
format = "%%{strftime(\\{\"%Y-%m-%dT%H:%M:%S%z\"\\}, time.start)}V|%%{client.as.number}V|%%{if(fastly.ff.visits_this_service == 0, \"true\", \"false\")}V"
68+
logging_datadog {
69+
name = "dd-oss-k8s"
70+
token = data.google_secret_manager_secret_version_access.datadog_api_key.secret_data
71+
region = "US5"
72+
format = templatefile("${path.module}/fastly-log-format.tftpl", {
73+
service_name = "cdn.dl.k8s.io",
74+
dd_app = "releases",
75+
dd_env = "prod",
76+
})
7777
}
7878

7979
snippet {

0 commit comments

Comments
 (0)