Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buddhi metric reporter service api #6

Merged
merged 17 commits into from
Jun 6, 2018
Merged

Conversation

eguzki
Copy link
Member

@eguzki eguzki commented Jun 4, 2018

Metric reporter endpoint computes expected metric usage from traffic information.

Buddhi knows relation between traffic paths and metric hits. Using that relation, metric usage report is generated based on traffic information.

Traffic information can be generated using /paths/amp endpoint as follows:

$ curl http://127.0.0.1:8089/paths/amp?lines=5 2>/dev/null > traffic.csv
$ cat traffic.csv
"53f07c14-e35e-4bfa-b0b1-9d3a993fad14.benchmark.3sca.net","/1?app_id=ddfa9a8842a3822e&app_key=73418183a69b027a"
"e75ef4f7-54da-4ec6-a4b2-33a163764385.benchmark.3sca.net","/1?app_id=5e4618aa57d801cd&app_key=fe4db52e5e86668f"
"e75ef4f7-54da-4ec6-a4b2-33a163764385.benchmark.3sca.net","/11?app_id=ceeeb23abfd0adfd&app_key=fbdfae99a587811e"
"31b75b9b-fbb4-4223-8736-b93c34676f04.benchmark.3sca.net","/1?user_key=aa5736e41a3888db"
"e75ef4f7-54da-4ec6-a4b2-33a163764385.benchmark.3sca.net","/111?app_id=ca2f8ff8b0a8707c&app_key=4b349db5bb77b9db"

Then, metric report can be generated requesting /report/amp endpoint as follows:

$ curl -X POST --data-binary "@traffic.csv" http://127.0.0.1:8090/report/amp 2>/dev/null
{"53f07c14-e35e-4bfa-b0b1-9d3a993fad14":{"6527c16b-dfeb-46e7-93d8-4eef0a6abbe3":1,"0dfb13fa-410e-4394-9fad-f0b785e1e680":1},"e75ef4f7-54da-4ec6-a4b2-33a163764385":{"dabdb86c-5344-4ff5-b8c7-65740357ecc6":6,"439402ef-ee9a-4c2a-856e-59928a3cef10":3,"e7265d03-efa7-4641-80b6-6d4a0d44713b":2,"937ebcef-1afd-4498-91a7-696c069f4668":1},"31b75b9b-fbb4-4223-8736-b93c34676f04":{"267c1777-53f7-4568-b9c0-2af28571a1dc":1,"2641b733-2030-4fac-9248-c1b8d3a4f02b":1}}

Report shows usage for every metric involved in traffic. Pretty printed

{
  "53f07c14-e35e-4bfa-b0b1-9d3a993fad14": {
    "6527c16b-dfeb-46e7-93d8-4eef0a6abbe3": 1,
    "0dfb13fa-410e-4394-9fad-f0b785e1e680": 1
  },
  "e75ef4f7-54da-4ec6-a4b2-33a163764385": {
    "dabdb86c-5344-4ff5-b8c7-65740357ecc6": 6,
    "439402ef-ee9a-4c2a-856e-59928a3cef10": 3,
    "e7265d03-efa7-4641-80b6-6d4a0d44713b": 2,
    "937ebcef-1afd-4498-91a7-696c069f4668": 1
  },
  "31b75b9b-fbb4-4223-8736-b93c34676f04": {
    "267c1777-53f7-4568-b9c0-2af28571a1dc": 1,
    "2641b733-2030-4fac-9248-c1b8d3a4f02b": 1
  }
}

Additionally, traffic path template from single traffic profile has been removed. Removing specific traffic path template for single profile, now, there is only one traffic path template for all traffic profiles based on /[1]{0..3} template.

@eguzki eguzki requested a review from davidor June 4, 2018 11:44
buddhi/README.md Outdated
$ curl -X POST --data-binary "@traffic.csv" http://127.0.0.1:8089/report/amp 2>/dev/null | jq '.'
{
"metrics": {
"24b08f30-403e-4be7-83d8-984d6e93b91a": 7,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A metric ID by itself does not identify a metric. It also needs the service ID.
If I remember correctly, Apisonator will let you create 2 different metrics with the same ID under different services.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct,

What format would be appropriate?

{
   "svc_a":{
       "metric_a_1": 3,
       "metric_a_2": 6,
        "metric_a_3": 8,
       }
   },
   "svc_b":{
       "metric_b_1": 1,
       "metric_b_2": 2,
        "metric_b_3": 7,
       }
   }
}

or CSV

"service", "metric", "counter"
"svc_a", "metric_a_1", 5
"svc_a", "metric_a_2", 5
"svc_a", "metric_a_3", 5
"svc_b", "metric_b_1", 5
"svc_b", "metric_b_2", 5
"svc_b", "metric_b_3", 5

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd return JSON in this case because it allows us to represent the service -> metric relationships

@eguzki eguzki force-pushed the buddhi-metric-counter-api branch from d6fe655 to ec47a71 Compare June 5, 2018 10:46
@eguzki
Copy link
Member Author

eguzki commented Jun 5, 2018

@davidor updated response body format to

{ service_id => { metric_id: counter} }

@eguzki eguzki merged commit b8ae4f2 into master Jun 6, 2018
@eguzki eguzki deleted the buddhi-metric-counter-api branch June 6, 2018 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants