Dmitry Kalashnik | 276d929 | 2019-04-16 15:26:21 +0400 | [diff] [blame^] | 1 | parameters: |
| 2 | _param: |
| 3 | elasticsearch_port: 9200 |
| 4 | fluentd: |
| 5 | agent: |
| 6 | config: |
| 7 | label: |
| 8 | notification_messages: |
| 9 | filter: |
| 10 | parse_publuisher_host: |
| 11 | tag: notification |
| 12 | type: parser |
| 13 | key_name: publisher_id |
| 14 | reserve_data: true |
| 15 | parser: |
| 16 | type: regexp |
| 17 | format: (?<publisher>\w+).(?<hostname>\w+) |
| 18 | save_hostname: |
| 19 | tag: notification |
| 20 | require: |
| 21 | - parse_publuisher_host |
| 22 | type: record_transformer |
| 23 | enable_ruby: true |
| 24 | record: |
| 25 | - name: Hostname |
| 26 | value: ${fluentd:dollar}{ record["hostname"] } |
| 27 | parse_source: |
| 28 | tag: notification |
| 29 | require: |
| 30 | - save_hostname |
| 31 | type: parser |
| 32 | key_name: event_type |
| 33 | reserve_data: true |
| 34 | parser: |
| 35 | type: regexp |
| 36 | format: (?<event_type_logger>\w+).+ |
| 37 | map_logger: |
| 38 | tag: notification |
| 39 | require: |
| 40 | - parse_source |
| 41 | type: record_transformer |
| 42 | enable_ruby: true |
| 43 | remove_keys: event_type_logger |
| 44 | record: |
| 45 | - name: Logger |
| 46 | value: ${fluentd:dollar}{ {'volume'=>'cinder', 'snapshot'=>'cinder', 'image'=>'glance', 'orchestration'=>'heat', 'identity'=>'keystone', 'compute'=>'nova', 'compute_task'=>'nova', 'scheduler'=>'nova', 'keypair'=>'nova', 'floatingip' =>'neutron', 'security_group' =>'neutron', 'security_group_rule' =>'neutron', 'network' =>'neutron', 'port' =>'neutron', 'router' =>'neutron', 'subnet' =>'neutron', 'sahara' =>'sahara'}[record["event_type_logger"]] } |
| 47 | get_payload_values: |
| 48 | tag: notification |
| 49 | require: |
| 50 | - map_logger |
| 51 | type: record_transformer |
| 52 | enable_ruby: true |
| 53 | record: |
| 54 | - name: Timestamp |
| 55 | value: ${fluentd:dollar}{ DateTime.strptime(record['timestamp'], '%Y-%m-%d %H:%M:%S.%N').strftime('%Y-%m-%dT%H:%M:%S.%3NZ') } |
| 56 | - name: severity_label |
| 57 | value: ${fluentd:dollar}{ record["priority"] } |
| 58 | - name: Severity |
| 59 | value: ${fluentd:dollar}{ {'TRACE'=>7,'DEBUG'=>7,'INFO'=>6,'AUDIT'=>6,'WARNING'=>4,'ERROR'=>3,'CRITICAL'=>2}[record['priority']].to_i } |
| 60 | - name: Hostname |
| 61 | value: '${fluentd:dollar}{ record["payload"].has_key?("host") ? record["payload"]["host"] : record["Hostname"] }' |
| 62 | - name: environment_label |
| 63 | value: ${_param:cluster_domain} |
| 64 | |
| 65 | - name: tenant_id |
| 66 | value: ${fluentd:dollar}{ record.dig("payload", "tenant_id") } |
| 67 | - name: user_id |
| 68 | value: ${fluentd:dollar}{ record.dig("payload", "user_id") } |
| 69 | - name: display_name |
| 70 | value: ${fluentd:dollar}{ record.dig("payload", "display_name") } |
| 71 | - name: vcpus |
| 72 | value: ${fluentd:dollar}{ record.dig("payload", "vcpus") } |
| 73 | - name: availability_zone |
| 74 | value: ${fluentd:dollar}{ record.dig("payload", "availability_zone") } |
| 75 | - name: instance_id |
| 76 | value: ${fluentd:dollar}{ record.dig("payload", "instance_id") } |
| 77 | - name: instance_type |
| 78 | value: ${fluentd:dollar}{ record.dig("payload", "instance_type") } |
| 79 | - name: image_name |
| 80 | value: ${fluentd:dollar}{ record.dig("payload", "image_name") } |
| 81 | - name: memory_mb |
| 82 | value: ${fluentd:dollar}{ record.dig("payload", "memory_mb") } |
| 83 | - name: disk_gb |
| 84 | value: ${fluentd:dollar}{ record.dig("payload", "disk_gb") } |
| 85 | - name: state |
| 86 | value: ${fluentd:dollar}{ record.dig("payload", "state") } |
| 87 | - name: old_state |
| 88 | value: ${fluentd:dollar}{ record.dig("payload", "old_state") } |
| 89 | - name: old_task_state |
| 90 | value: ${fluentd:dollar}{ record.dig("payload", "old_task_state") } |
| 91 | - name: new_task_state |
| 92 | value: ${fluentd:dollar}{ record.dig("payload", "new_task_state") } |
| 93 | - name: network_id |
| 94 | value: ${fluentd:dollar}{ record.dig("payload", "network_id") } |
| 95 | - name: subnet_id |
| 96 | value: ${fluentd:dollar}{ record.dig("payload", "subnet_id") } |
| 97 | - name: port_id |
| 98 | value: ${fluentd:dollar}{ record.dig("payload", "port_id") } |
| 99 | - name: volume_id |
| 100 | value: ${fluentd:dollar}{ record.dig("payload", "volume_id") } |
| 101 | - name: size |
| 102 | value: ${fluentd:dollar}{ record.dig("payload", "size") } |
| 103 | - name: status |
| 104 | value: ${fluentd:dollar}{ record.dig("payload", "status") } |
| 105 | - name: replication_status |
| 106 | value: ${fluentd:dollar}{ record.dig("payload", "replication_status") } |
| 107 | pack_payload_to_json: |
| 108 | tag: notification |
| 109 | require: |
| 110 | - get_payload_values |
| 111 | type: record_transformer |
| 112 | enable_ruby: true |
| 113 | remove_keys: '["timestamp", "publisher_id", "priority", "notification_type", "payload"]' |
| 114 | record: |
| 115 | - name: Payload |
| 116 | value: ${fluentd:dollar}{ record["payload"].to_json } |
| 117 | match: |
| 118 | notifications_output: |
| 119 | tag: notification |
| 120 | type: elasticsearch |
| 121 | host: ${_param:stacklight_log_address} |
| 122 | port: ${_param:elasticsearch_port} |
| 123 | es_index_name: notification |
| 124 | tag_key: Type |