Skip to content

Instantly share code, notes, and snippets.

@mateobur
mateobur / sysdigevent2.json
Created March 6, 2018 18:22
Sysdig event webhook
{
"id": 14787,
"version": 18,
"createdOn": 1511433414000,
"modifiedOn": 1519828577000,
"type": "WEBHOOK",
"enabled": true,
"sendTestNotification": false,
"name": "Splunk",
"options": {
@mateobur
mateobur / sysdigevent.json
Last active February 7, 2019 07:32
Sysdig Event Webhook
...
{
"id": 14787,
"version": 17,
"createdOn": 1511433414000,
"modifiedOn": 1519827129000,
"type": "WEBHOOK",
"enabled": true,
"sendTestNotification": true,
"name": "Splunk",
@mateobur
mateobur / custommetrics.yml
Created February 19, 2018 19:50
Custom Metrics Kubernetes Sysdig
- name: custom-metrics-server
image: mateobur/custom-metrics-adapter:latest
args:
- --deploymentname=flask
- --servicename=flask
- --kubernetesnamespace=default
- --targetmetric=net.http.request.count
- --metrics-relist-interval=30s
- --v=10
- --logtostderr=true
@mateobur
mateobur / MetricValue.go
Created February 19, 2018 19:45
Metric Value Kubernetes Sysdig
&custom_metrics.MetricValue{
DescribedObject: custom_metrics.ObjectReference{
APIVersion: info.GroupResource.Group + "/" + runtime.APIVersionInternal,
Kind: kind.Kind,
Name: name,
Namespace: namespace,
},
MetricName: info.Metric,
Timestamp: metav1.Time{time.Now()},
Value: *resource.NewMilliQuantity(int64(metricdatapoint*1000.0), resource.DecimalSI),
@mateobur
mateobur / CustomMetricsProvider.go
Created February 19, 2018 19:42
Custom Metrics Provider Kubernetes Sysdig
type CustomMetricsProvider interface {
// GetRootScopedMetricByName fetches a particular metric for a particular root-scoped object.
GetRootScopedMetricByName(groupResource schema.GroupResource, name string, metricName string) (*custom_metrics.MetricValue, error)
// GetRootScopedMetricByName fetches a particular metric for a set of root-scoped objects
// matching the given label selector.
GetRootScopedMetricBySelector(groupResource schema.GroupResource, selector labels.Selector, metricName string) (*custom_metrics.MetricValueList, error)
// GetNamespacedMetricByName fetches a particular metric for a particular namespaced object.
GetNamespacedMetricByName(groupResource schema.GroupResource, namespace string, name string, metricName string) (*custom_metrics.MetricValue, error)
@mateobur
mateobur / prepare.yml
Created January 23, 2018 23:24
Prepare OpenShift Ansible Sysdig hosts
---
- hosts: nodes
gather_facts: no
pre_tasks:
- name: 'install python2'
raw: sudo yum install -y python
tasks:
- name: upgrade packages
@mateobur
mateobur / AnsibleOpenshiftSysdighost
Last active February 7, 2019 07:54
Ansible Openshift Sysdig host
[OSEv3:children]
masters
etcd
nodes
[OSEv3:vars]
ansible_ssh_user=centos
ansible_sudo=true
ansible_become=true
@mateobur
mateobur / CloudFormationTemplateOpenShift.yaml
Created January 23, 2018 22:19
CloudFormation Template OpenShift
AWSTemplateFormatVersion: '2010-09-09'
Metadata: {}
Parameters:
###########
KeyName:
Description: The EC2 Key Pair to allow SSH access to the instance
Type: 'AWS::EC2::KeyPair::KeyName'
AvailabilityZone:
Description: Availability zone to deploy
@mateobur
mateobur / custommetrics.py
Created December 20, 2017 14:22
Kubernetes scaler custom metrics Prometheus Sysdig Monitor
from flask import Flask, request
import os
from sdcclient import SdcClient
app = Flask(__name__)
sdclient = SdcClient(open("/etc/sysdigtoken/token.txt","r").read().rstrip())
metrics = [{ "id": "net.http.request.count", "aggregations": { "time": "timeAvg", "group": "avg" } }]
podname = os.environ['POD_NAME']
def get_request_time():
@mateobur
mateobur / docker-compose.yml
Created December 12, 2017 16:07
Prometheus alerts integration example, docker-compose file
version: '2'
services:
pythonmetrics:
image: mateobur/pythonmetric
ports:
- 9100:9100
restart: on-failure
networks: