CleverCloud / clever-components

Collection of Web Components by Clever Cloud
https://www.clever-cloud.com/doc/clever-components/
Apache License 2.0
221 stars 20 forks source link

cc-tile-metrics: init small metrics tile component for overview #240

Closed hsablonniere closed 1 year ago

hsablonniere commented 3 years ago

Display

We need a small tile component to display some rough metrics (CPU and RAM).

image

Details about the chart

Inputs

Outputs

None

Wording / i18n

Data & smart component integration

vballu commented 3 years ago

Applications metrics in Clever Cloud

source :

Summary :

Metrics are store as geotime series (GTS) in Warp 10.

A geotime series contains two parts :

class and labels are used to access to the data.

RAM / CPU

timespan follow https://www.wikiwand.com/en/ISO_8601#/Durations

The exec endpoint

Call the Warp 10 exec endpoint (https://www.warp10.io/content/03_Documentation/03_Interacting_with_Warp_10/09_Analysing_data)

exec a warpscript.

warpscript.mc2 :

'READ_TOKEN' 'data_token' STORE
NOW 'NOW' STORE
{
'token' $data_token
'class' 'mem.available_percent' 
'labels' { 'app_id' 'app_958b2ff1-XXXX-XXXX-XXXX-XXXXXXXXXXXX' }
'start' $NOW 1 h -
'end' $NOW
} FETCH
curl -X POST --data @warpscript.mc2 'https://c1-warp10-clevercloud-customers.services.clever-cloud.com/api/v0/exec'

Beware of space in the warpscipt files

output

The output is a list of GTS looking like as followed

[
{"c":"mem.available_percent","l":{"image_variant":"kibana",".app":"metrics","owner_id":"orga_XXXXXXX-XXX-XXX-XXXXXXXX","datacenter":"par4","source":"telegraf","instance_source":"apps","flavor_name":"S","vm_type":"volatile","zone":"par","hypervisor":"hv-par4-XXXX","host":"XXXX-XXXX-XXXX-bc10-6a5098f7fb6f","deployment_id":"XXXX","app_id":"app_958b2ff1-XXXX-XXXX-XXXX-XXXXXXXXXXXX","image_type":"node"},"a":{},"la":1628513282565,"v":[[1628516642000000,67.809205],[1628516582000000,67.734481],[1628516522000000,67.746737],[1628516462000000,67.748121],[1628516402000000,67.783902],[1628516342000000,67.794774],[1628516282000000,67.821264],....]},
 ....]

Handle the granularity / How to split on instances

In Clever Cloud, each instance has is owned instance_id as label.

Hence, we have this ordinal inclusion rules :

 Instances ⊆ Applications ⊆ Organisations 

In other words, each GTS (dictionary) in the output list should be an instance.

Token / Rights

There is a token api in Clever Cloud to get the right token depending of the user

If we need something more complex or a more specific output, easier to be handle ?

Increase performance

Many things can be done to increase Fetch performance.

As not many points are needed for this component. The data can be sample during the fetch using the sample parameter :

ex :

curl -vvv -H 'X-Warp10-Token: TOKEN.' 'https://c1-warp10-clevercloud-customers.services.clever-cloud.com/api/v0/fetch?&now=now&timespan=P1H&sample=0.01&selector=mem.available_percent\{app_id=app_XXX\}&format=json'
vballu commented 3 years ago

I highly recommand to use the fetch endpoint

hsablonniere commented 3 years ago

@Galimede Here are some details:

^^ Those are just ideas, I'll let you see what's best.

hsablonniere commented 2 years ago

TODO:

hsablonniere commented 2 years ago

@Galimede Note for later, now that we chose to select "round" hours time windows, the number is not the live one. We need to discuss this.

hsablonniere commented 2 years ago

Feedbacks:

florian-sanders-cc commented 2 years ago

We need to move colors to the theme and reuse tokens

Galimede commented 1 year ago

Blocked by: https://github.com/CleverCloud/clever-client.js/pull/70