diff options
| author | fumingwei <[email protected]> | 2023-11-23 15:30:48 +0800 |
|---|---|---|
| committer | fumingwei <[email protected]> | 2023-11-23 15:37:08 +0800 |
| commit | 386e154ddb5ab322c4a489b6c6b3a172de44788e (patch) | |
| tree | 7f9f0b63d2aa81dd3d4da6c11a505e7810768302 | |
| parent | d1f72eda03ba7d0139c8f51b2d8efbabe9beb1b5 (diff) | |
bugfix:print_table add default args verbose
| -rw-r--r-- | readme_fieldstat_easy.md | 2 | ||||
| -rw-r--r-- | src/exporter/fieldstat_exporter.py | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/readme_fieldstat_easy.md b/readme_fieldstat_easy.md index 13bf0e3..48fdc69 100644 --- a/readme_fieldstat_easy.md +++ b/readme_fieldstat_easy.md @@ -140,7 +140,7 @@ Export the metrics of type counter in the form of a determinant. We can use the template argument to exporter table format. The template argument include the follow functions: functions|description|jinja2 example ---|---|--- -print_tables(groupby, columns)|Groupby specifies the tag key as the row of the table. Column specifies the field key as the column of the table. Default print speed value.| '{{ print_tables("send_log", ["T_success_log"]) }}{{"\n"}}{{ print_tables("groupby", ["T_fail_log"], False) }}' +print_tables(groupby, columns, enable_speed=True, verbose=False)|Groupby specifies the tag key as the row of the table. Column specifies the field key as the column of the table. Default print speed value. When verbose is True, row name contains information about all tags. | '{{ print_tables("send_log", ["T_success_log"]) }}{{"\n"}}{{ print_tables("groupby", ["T_fail_log"], False) }}' print_counters(field_keys)| Export counter metrics specified by the field keys.|'{{ print_counters(["T_success_log"]) }}' print_histograms(field_keys)| Export histogram metrics specified by the field keys.|'{{ print_histograms(["list_num"]) }}' print_hlls(field_keys)| Export hyperloglog metrics specified by the field keys.| '{{ print_hlls(["external_ip"]) }}' diff --git a/src/exporter/fieldstat_exporter.py b/src/exporter/fieldstat_exporter.py index a40481d..7e6c5be 100644 --- a/src/exporter/fieldstat_exporter.py +++ b/src/exporter/fieldstat_exporter.py @@ -336,8 +336,11 @@ class TableFormatTable: return #exporter table row name. + row_str = [] for key, value in tags.items(): - row.append("%s_%s" % (key, str(value))) + #row.append("%s_%s" % (key, str(value))) + row_str.append("%s_%s" % (key, str(value))) + row.append('&'.join(row_str)) #exporter table row value. sorted_keys = sorted(fields.keys()) @@ -637,7 +640,7 @@ class LocalExporter: self.build_not_table_format_exporter(self.objects_matched) - def print_table_format(self, groupby, columns, enable_speed=True): + def print_table_format(self, groupby, columns, enable_speed=True, verbose=False): table_fields=[] for item in self.objects_matched: is_print_table = True @@ -662,9 +665,10 @@ class LocalExporter: if key not in columns: new_fields["fields"].pop(key) - for key in tags: - if groupby != key: - new_fields["tags"].pop(key) + if not verbose: + for key in tags: + if groupby != key: + new_fields["tags"].pop(key) # if enable_speed == False: # new_fields["fields_delta"] = {} |
