Skip to content

Instantly share code, notes, and snippets.

View jnahelou's full-sized avatar

jnahelou

View GitHub Profile
@jnahelou
jnahelou / medium.tf
Created July 27, 2021 15:48
code sample - grafana medium story
terraform {
required_providers {
grafana = {
source = "grafana/grafana"
}
}
}
resource "grafana_dashboard" "test" {
config_json = <<EOD
{
@jnahelou
jnahelou / .terraformrc
Created July 27, 2021 15:51
override provider in terraform 0.14+
provider_installation {
dev_overrides {
"registry.terraform.io/grafana/grafana" = "<path_to_binary>"
}
direct {}
}
@jnahelou
jnahelou / ci.yml.j2
Last active October 26, 2021 12:27
python cookiecutter ci example
name: CI
on:
push:
pull_request:
branches: [master]
jobs:
Quality:
runs-on: ubuntu-latest
steps:
@jnahelou
jnahelou / monitoring.tf.j2
Last active October 26, 2021 12:27
Draft cookiecutter template to monitore cloud functions
{%- if cookiecutter.use_monitoring == "datadog" %}
provider "datadog" {
api_url = "https://api.datadoghq.eu/"
}
resource "datadog_monitor" "alert-slack" {
name = "{{cookiecutter.project_name}} function errored"
type = "metric alert"
message = "{{cookiecutter.project_name}} completion in error !"
query = "sum(last_5m):sum:gcp.cloudfunctions.function.execution_count{function_name:${var.function_name},status:error,project_id:${var.project_id}}.as_count() > 0"
@jnahelou
jnahelou / main.py
Last active May 12, 2022 16:08
List users with ssh keys
import googleapiclient.discovery
compute_v1 = googleapiclient.discovery.build(
"compute", "v1", cache_discovery=False
)
project_id = "<project_id>"
project_info = compute_v1.projects().get(project=project_id).execute()
receivers: [0/45]
elasticsearch/elasticsearch_elasticsearch:
collection_interval: 30s
endpoint: https://my-deployment-<CHANGEME>.es.europe-west1.gcp.cloud.es.io
nodes: ["_local"]
password: <CHANGEME>
skip_cluster_metrics: false
tls:
insecure: false
username: elastic
@jnahelou
jnahelou / sample.py
Last active August 25, 2022 09:49
medium logging
import logging
import requests
import json
from opentelemetry.instrumentation.logging import LoggingInstrumentor
metadata_server = "http://metadata/computeMetadata/v1/"
metadata_flavor = {'Metadata-Flavor': 'Google'}
project_id = requests.get(
metadata_server + 'project/project-id', headers=metadata_flavor).text