| 1 |
; |
| 2 |
; Asterisk Call Detail Record Logging (CDR) - Custom DSV Backend |
| 3 |
; |
| 4 |
|
| 5 |
; This is the configuration file for the customizable DSV backend for CDR |
| 6 |
; logging. |
| 7 |
; |
| 8 |
; DSV?? Delimiter Separated Values because the field delimiter doesn't have |
| 9 |
; to be a comma. |
| 10 |
; |
| 11 |
; Legacy vs Advanced Mappings |
| 12 |
; |
| 13 |
; Legacy mappings are those that are defined using dialplan functions like CDR |
| 14 |
; and CSV_QUOTE and require a VERY expensive function replacement process at |
| 15 |
; runtime for every record output. |
| 16 |
; |
| 17 |
; Advanced mappings are those that are defined by a list of field names and |
| 18 |
; parameters that define the field separator and quote character you want to use. |
| 19 |
; This type of mapping is uses significantly less resources at runtime. |
| 20 |
; |
| 21 |
; |
| 22 |
; Legacy Mappings |
| 23 |
; |
| 24 |
; Within a legacy mapping, use the CDR() and CSV_QUOTE() functions to retrieve |
| 25 |
; values from the CDR. |
| 26 |
; |
| 27 |
; NOTE: If your legacy mapping uses commas as field separators and only the CSV_QUOTE |
| 28 |
; and CDR dialplan functions, the module will attempt to strip the functions and |
| 29 |
; and create a much faster advanced mapping for it. However, we urge you to create |
| 30 |
; a real advanced mapping and not rely on this process. If the mapping contains |
| 31 |
; something not recognized it will go the slower legacy route. |
| 32 |
; |
| 33 |
; Each entry in the "mappings" category represents a separate output file. |
| 34 |
; A filename that starts with a forward-slash '/' will be treated as an absolute |
| 35 |
; path name. If it doesn't, it must be a file name with no directory separators |
| 36 |
; which will be placed in the /var/log/asterisk/cdr-custom directory. |
| 37 |
; |
| 38 |
;[mappings] |
| 39 |
;Master.csv => ${CSV_QUOTE(${CDR(clid)})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})},${CSV_QUOTE(${CDR(dcontext)})},${CSV_QUOTE(${CDR(channel)})},${CSV_QUOTE(${CDR(dstchannel)})},${CSV_QUOTE(${CDR(lastapp)})},${CSV_QUOTE(${CDR(lastdata)})},${CSV_QUOTE(${CDR(start)})},${CSV_QUOTE(${CDR(answer)})},${CSV_QUOTE(${CDR(end)})},${CSV_QUOTE(${CDR(duration)})},${CSV_QUOTE(${CDR(billsec)})},${CSV_QUOTE(${CDR(disposition)})},${CSV_QUOTE(${CDR(amaflags)})},${CSV_QUOTE(${CDR(accountcode)})},${CSV_QUOTE(${CDR(uniqueid)})},${CSV_QUOTE(${CDR(userfield)})},${CDR(sequence)} |
| 40 |
; |
| 41 |
; High Resolution Time for billsec and duration fields |
| 42 |
;Master.csv => ${CSV_QUOTE(${CDR(clid)})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})},${CSV_QUOTE(${CDR(dcontext)})},${CSV_QUOTE(${CDR(channel)})},${CSV_QUOTE(${CDR(dstchannel)})},${CSV_QUOTE(${CDR(lastapp)})},${CSV_QUOTE(${CDR(lastdata)})},${CSV_QUOTE(${CDR(start)})},${CSV_QUOTE(${CDR(answer)})},${CSV_QUOTE(${CDR(end)})},${CSV_QUOTE(${CDR(duration,f)})},${CSV_QUOTE(${CDR(billsec,f)})},${CSV_QUOTE(${CDR(disposition)})},${CSV_QUOTE(${CDR(amaflags)})},${CSV_QUOTE(${CDR(accountcode)})},${CSV_QUOTE(${CDR(uniqueid)})},${CSV_QUOTE(${CDR(userfield)})},${CDR(sequence)} |
| 43 |
;Simple.csv => ${CSV_QUOTE(${EPOCH})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})} |
| 44 |
|
| 45 |
|
| 46 |
; |
| 47 |
; Advanced Mappings |
| 48 |
; |
| 49 |
; Each category in this file other than "mappings" represents a separate output file. |
| 50 |
; A filename that starts with a forward-slash '/' will be treated as an absolute |
| 51 |
; path name. If it doesn't, it must be a file name with no directory separators |
| 52 |
; which will be placed in the /var/log/asterisk/cdr-custom directory. |
| 53 |
; |
| 54 |
;[cdr_master.csv] ; Output file or path name. |
| 55 |
|
| 56 |
;format = dsv ; Advanced mappings can actually have two types |
| 57 |
; "dsv" or "json". This example uses "dsv", which |
| 58 |
; is the default, but see the example below for more |
| 59 |
; info on the json format. |
| 60 |
|
| 61 |
;separator_character = , ; The character to use for the field separator, |
| 62 |
; It defaults to a comma but you can use any |
| 63 |
; character you want. For instance, specify |
| 64 |
; \t to separate the fields with a tab. |
| 65 |
|
| 66 |
;quote_character = " ; The character to use as the quote character. |
| 67 |
; It defaults to the double quote but again, it |
| 68 |
; can be any character you want although the |
| 69 |
; single-quote is the only other one that makes |
| 70 |
; sense. |
| 71 |
|
| 72 |
;quote_escape_character = " ; The character to use to escape the quote_character |
| 73 |
; should the quote character actually appear in the |
| 74 |
; field output. A good example of this is a caller |
| 75 |
; id string like "My Name" <1000>. For true CSV |
| 76 |
; compatibility, it must be the same as the quote |
| 77 |
; character but a backslash might be acceptable for |
| 78 |
; other formats. |
| 79 |
|
| 80 |
;quoting_method = all ; Nothing says you _have_ to quote anything. The only |
| 81 |
; time a field MUST be quoted is if it contains the |
| 82 |
; separator character and this is handled automatically. |
| 83 |
; Additionally, the following options are available: |
| 84 |
; "all": Quote all fields. The default. |
| 85 |
; "non_numeric": Quote all non numeric fields. |
| 86 |
; "none": Don't quote any field (unless it contains |
| 87 |
; a separator character). |
| 88 |
|
| 89 |
;fields = clid,"Some Literal",src, dst, dcontext, channel, dstchannel, lastapp, lastdata, start, answer, end, duration, billsec, disposition, amaflags, accountcode, uniqueid(noquote), userfield, sequence,ds_type(uservar) |
| 90 |
; This is the list of fields to include in the record. The field names are the |
| 91 |
; same as in the legacy mapping but without any enclosing dialplan functions. |
| 92 |
; You can specify literals to be placed in the output record by double-quoting |
| 93 |
; them. There is also some special notation available in the form of "qualifiers". |
| 94 |
; A qualifier is a list of tags, separated by the '^' character and placed |
| 95 |
; directly after the field name and enclosed in parentheses. |
| 96 |
; |
| 97 |
; All fields can accept the "quote" or "noquote" qualifier when you want to exempt |
| 98 |
; a field from the "quoting_method" policy. For example, when quoting_method=all, |
| 99 |
; you can force the uniqueid field to not be quoted with `uniqueid(noquote)`. The |
| 100 |
; example in fields above shows this. |
| 101 |
; |
| 102 |
; If you've added user variables to the CDR using the CDR() dialplan function in |
| 103 |
; extensions.conf, you'll need to retrieve the field using the "uservar" qualifier. |
| 104 |
; For example, if you've added the "ds_type" variable, you'll need to retrieve |
| 105 |
; it with `ds_type(uservar)`. |
| 106 |
; |
| 107 |
; The default output format for the "start", "answer" and "end" timestamp fields |
| 108 |
; is the "%Y-%m-%d %T" strftime string format however you can also format those |
| 109 |
; fields as an int64 or a double: `start(int64)` or `start(double)` or |
| 110 |
; provide your own strftime format string: `start(%FT%T%z)`. |
| 111 |
; |
| 112 |
; The "disposition" and "amaflags" are formatted as their string names like |
| 113 |
; "ANSWERED" and "DOCUMENTATION" by default but if you just want the numbers and |
| 114 |
; not the names... `amaflags(int64),disposition(int64)`. |
| 115 |
; |
| 116 |
; If you need to combine flags, use the caret '^' symbol: `start(int64^noquote)` |
| 117 |
; |
| 118 |
; Final notes about "fields": |
| 119 |
; Field names and qualifiers aren't case sensitive. |
| 120 |
; You MUST use the comma to separate the fields, not the "separator_character". |
| 121 |
; You MUST use the double-quote to indicate literal fields, not the "quote_character". |
| 122 |
; Whitespace in "fields" is ignored except in literals. |
| 123 |
|
| 124 |
; |
| 125 |
; An Advanced JSON example: |
| 126 |
; |
| 127 |
;[cdr_master.json] |
| 128 |
;format = json |
| 129 |
;fields = clid,"My: Literal",src, dst, dcontext, channel, dstchannel, lastapp, lastdata, start, answer, end, duration, billsec, disposition, amaflags, accountcode, uniqueid(noquote), userfield, sequence,ds_type(uservar) |
| 130 |
; |
| 131 |
; In order to ensure valid JSON, the following settings are forced: |
| 132 |
; The separator character is always the comma. |
| 133 |
; The quote character is always the double-quote. |
| 134 |
; The quote escape character is always the backslash. |
| 135 |
; The quoting method is always "non_numeric". |
| 136 |
; |
| 137 |
; Since JSON requires both a name and value, the name is always |
| 138 |
; the field name. For literals however you must specify the literal |
| 139 |
; as a "name: value" pair as demonstrated above. The output record |
| 140 |
; would then look something like: |
| 141 |
; {"clid":"\"Alice\" <1000>", "My":"Literal","src":"1000","dst":"18005551212", ...} |
| 142 |
|
| 143 |
|
| 144 |
|