Skip to content

Instantly share code, notes, and snippets.

View renshuki's full-sized avatar
💭
🇫🇷 🇯🇵 🇺🇸

Francois-Clement Brossard renshuki

💭
🇫🇷 🇯🇵 🇺🇸
View GitHub Profile
@renshuki
renshuki / apache_extfilter_change_url_onfly.md
Last active March 18, 2019 13:28
Apache extfilter module to replace URLs on the fly (while you access a website Apache automatically translate the address)

ExtFilterDefine fixtext mode=output intype=text/html cmd="/bin/sed s#www\.example1\.com#www\.example2\.com#g"

@renshuki
renshuki / count_number_of_files_in_directory.md
Last active March 18, 2019 13:28
Command to count the number of files in a directory

find DIR_NAME -type f | wc -l

@renshuki
renshuki / regex_remove_html_tags.md
Last active March 18, 2019 13:29
A regex to remove HTML tags

<[^>]*>

@renshuki
renshuki / reset_files_and_folders_permissions.md
Last active March 18, 2019 13:19
Reset files and folders permissions
chown -R user:group
find directory_path -type d -exec chmod 775 {} \;
find directory_path -type f -exec chmod 664 {} \;
@renshuki
renshuki / elasticsearch_watcher_action_index_add_field_webhook.md
Created March 18, 2019 13:35
Elasticsearch Watcher (Alert) to index payload to a new one via index action and add a new field using a webhook
{
  "trigger": {
    "schedule": {
      "interval": "10s"
    }
  },
  "input": {
    "search": {
      "request": {
@renshuki
renshuki / elasticsearch_term_aggregation_bucket_count_cardinality.md
Created March 18, 2019 13:41
Elasticsearch term aggregation to regroup a field (key) and count the number of buckets using cardinality aggregation
GET rule_index/_search
{
  "size": 0,
  "aggs": {
    "rule_doc_count": {
      "terms" : { "field" : "key.keyword" }
    },
    "rule_count":{
 "cardinality": {
@renshuki
renshuki / elastic_cloud_remote_monitoring_cluster_configuration.md
Created April 12, 2019 07:58
Remote monitoring cluster configuration for Elasticsearch Service (formely Elastic Cloud)
PUT _cluster/settings
{
  "persistent": {
    "xpack": {
      "monitoring": {
        "collection": {
          "enabled": "true",
          "interval": "10s"
 },
@renshuki
renshuki / elasticsearch_add_timestamp_automatically_at_ingestion_time.md
Created April 16, 2019 04:15
Elasticsearch - Ingest pipeline to add a timestamp field to a document at the time of the ingestion

Create the ingest pipeline

PUT _ingest/pipeline/timestamp
{
  "description": "Add a timestamp field to a document at the time of the ingestion",
  "processors": [
    {
      "set": {
 "field": "@timestamp",
@renshuki
renshuki / elasticsearch_watcher_logstash_heap_usage.md
Last active May 8, 2019 07:31
Elasticsearch Threshold Alert (Watcher) to monitor Logstash instance heap usage

This watcher check every 5 minutes if the average heap usage of the Logstash instance is above 80%.

An action could be added to send emails automatically

  "watch" : {
    "trigger" : {
      "schedule" : {
        "interval" : "5m"
      }
@renshuki
renshuki / elasticsearch_watcher_logstash_monitoring_events.md
Last active August 14, 2020 09:51
Elasticsearch Threshold Alert (Watcher) to check Logstash instance monitoring incoming events

This watcher check every 5 minutes if the number of Logstash monitoring events are below 1 which means Logstash monitoring is in trouble.

"watch" : {
    "trigger" : {
      "schedule" : {
        "interval" : "5m"
      }
    },
    "input" : {