Unit Converter from Grafana to Guance
Quick view
In Grafana and Guance Dashboard, there are many units to represent to data semantic.
This package is a converter to convert the unit string from Grafana to Guance.
The implementation steps are:
- Get the full list of units from Grafana.
- Extract all the units from source code of Guance Cloud Console by tree-sitter query.
- Compare the units from Grafana and Guance, and find the mapping relationship.
The Guance Cloud Console is written in React, and the source code is compiled to JavaScript.
The tree-sitter is a parser generator tool and incremental parsing library. It can extract any information from source code and its CST (Concrete Syntax Tree).
The query as follows:
; extract the unit formats
(program
(expression_statement
(assignment_expression left:
(identifier) right:
(object [
(pair key: (string) @id)
(pair key: (property_identifier) @id)
])
)
)
)
The steps to extract the units from Guance:
- Clone the frontend source code of Guance Cloud Console.
- cd
lib/convert-units/lib/definitions
folder.
- Run the script
node main.js
.