Skip to content

Example: CDR to HEP

Lorenzo Mangani edited this page Dec 8, 2017 · 5 revisions

CDR Correlation

In this example, we'll correlate CSV CDRs to SIP Sessions in HOMER using:

By default, only newlines will be processed by Input. For more options, consults the docs.

*NOTE: CSV Header must match 100% or inconsistencies will appear!

Recipe (full CDR)

This recipe will parse the input using the CSV headers in configuration, extract a correlation field, and ship the full CDR as a HEP JSON log.

input {
  file {
    path => '/path/to/Master.csv'
  }
}

filter {
  csv {
    headers => ['ID', 'caller_id_name', 'caller_id_number', 'destination_number', 'context', 'start_stamp', 'answer_stamp', 'end_stamp', 'durration', 'billsec', 'hangup_cause', 'uuid', 'bleg_uuid', 'accountcode', 'read_codec', 'write_codec', 'sip_call_id', 'lcr_carrier', 'lcr_rate', 'hangup_cause_q850', 'proto_specific_hangup_cause', 'userfield', 'st_src_ip', 'network_address', 'progressusec', 'progress_mediausec', 'channel_name', 'cust_field1', 'cust_field2', 'cust_field3', 'cust_field4', 'cust_field5', 'st_mg_name', 'direction', 'provider_code', 'sip_Privacy', 'originating_leg_uuid', 'sip_hangup_disposition', 'recording_name', 'last_bridge_proto_specific_hangup_cause', 'call_uuid', 'sip_h_X_StUUID', 'dialed_number', 'privacy_hide_number', 'privacy_hide_name', 'lcr_key', 'call_type', 'cdr_version_flag', 'inb_leg_client_code', 'out_leg_client_code', 'bill_call_type', 'client_dialed_number', 'system_dialed_number']
  }
  compute_field {
    field => correlation_id
    value => "#{sip_call_id}"
  }
}

output {
  hep {
    host => 127.0.0.1
    port => 9060
    hep_id => 2022
    hep_type => 100
  }
}

Recipe (Custom CDR)

This recipe will parse the input using the CSV headers in configuration, extract a correlation field, create a custom payload using Mustache syntax, and ship the custom CDR as a HEP JSON log.

input {
  file {
    path => '/path/to/Master.csv'
  }
}

filter {
  csv {
    headers => ['ID', 'caller_id_name', 'caller_id_number', 'destination_number', 'context', 'start_stamp', 'answer_stamp', 'end_stamp', 'durration', 'billsec', 'hangup_cause', 'uuid', 'bleg_uuid', 'accountcode', 'read_codec', 'write_codec', 'sip_call_id', 'lcr_carrier', 'lcr_rate', 'hangup_cause_q850', 'proto_specific_hangup_cause', 'userfield', 'st_src_ip', 'network_address', 'progressusec', 'progress_mediausec', 'channel_name', 'cust_field1', 'cust_field2', 'cust_field3', 'cust_field4', 'cust_field5', 'st_mg_name', 'direction', 'provider_code', 'sip_Privacy', 'originating_leg_uuid', 'sip_hangup_disposition', 'recording_name', 'last_bridge_proto_specific_hangup_cause', 'call_uuid', 'sip_h_X_StUUID', 'dialed_number', 'privacy_hide_number', 'privacy_hide_name', 'lcr_key', 'call_type', 'cdr_version_flag', 'inb_leg_client_code', 'out_leg_client_code', 'bill_call_type', 'client_dialed_number', 'system_dialed_number']
  }
  compute_field {
    field => correlation_id
    value => "#{sip_call_id}"
  }
  mustache {
    template => 'CDR: {{direction}} {{caller_id_number}} -> {{destination_number}}: {{lcr_carrier}} {{lcr_rate}}'
    target_field => 'payload'
  }
}

output {
  hep {
    host => 127.0.0.1
    port => 9060
    hep_id => 2022
    hep_type => 100
  }
}

Clone this wiki locally