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

Specification for exposing apis to access time-series data #63

Merged
merged 7 commits into from
Jan 11, 2017

Conversation

anmolbabu
Copy link
Contributor

tendrl-bug-id: #62
Signed-off-by: anmolbabu anmolbudugutta@gmail.com

tendrl-bug-id: Tendrl#62
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
@anmolbabu
Copy link
Contributor Author

anmolbabu commented Dec 13, 2016

@anivargi I have documented from monitoring perspective could you please add specifics from the perspective of tendrl-api

@anivargi @shtripat @nthomas-redhat @r0h4n @brainfunked please review.

TODO: Create issues on related components and link it in spec

The above response gives the statistics for last 24 hours corresponding to the
'resource_name' passed to it. If a time range is passed as optional arguements
to the above api, then the api responds with the statistics for that time
range.
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a sample for time range based invocation as well here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

=== Developer impact:

This has extensive impact on 2 modules tendrl-api and performance-monitoring
and hence warrants a very high collaboration between the implementers of the
Copy link
Member

Choose a reason for hiding this comment

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

%s/implementers/owners/g

tendrl-bug-id: Tendrl#62
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Copy link
Member

@shtripat shtripat left a comment

Choose a reason for hiding this comment

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

LGTM other than two minor comments I have.

=== Assignee(s):


Who is leading the writing of the code? Or is this a spec where you're
Copy link
Member

Choose a reason for hiding this comment

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

I feel line 253-257 is not required. Its retained from sample I feel. Please remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I was adding to the template and while doing so I forgot to remove this :)

touching any other part of the code.
*** The way the plugins work is :
**** The interfaces to time-series db are added under the directory
tendrl/performance-monitoring/time_series_db/dbplugins of
Copy link
Contributor

Choose a reason for hiding this comment

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

If these are etcd directories, please use "tendrl/" instead of "tendrl/", Etcd hides directories with a leading "" and we need to use it

Copy link
Contributor Author

@anmolbabu anmolbabu Dec 15, 2016

Choose a reason for hiding this comment

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

No it is location in tendrl/performance-monitoring code-base where the specific time-series db handlers need to be added

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case, omit the tendrl/performance-monitoring prefix from the directory name, since you've mentioned the repository name at the end of the sentence anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

***** Since the manager is a singleton, there is only one instance
of it throughout the life of Tendrl/performance-monitoring
application which means all this house-keeping is done only
once during the lifecycle of the application.
Copy link
Contributor

Choose a reason for hiding this comment

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

Line 58-87, does this implementaion covered as part of this spec?

Copy link
Contributor Author

@anmolbabu anmolbabu Dec 15, 2016

Choose a reason for hiding this comment

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

This spec talks about apis that fetch time series data. So I added more details like how the apis actually fetch the details i.e, the api talks to a manager that takes the responsibility of finding the correct plugins that actually talks to time-series db

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

]
----------

The above response gives the statistics for last 24 hours corresponding to the
Copy link
Contributor

Choose a reason for hiding this comment

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

is this the latest value or 24 hours value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is 24 hours value :) I cut short the sample because it was too huge and symbolically added ',.... ' notation

Copy link
Contributor

Choose a reason for hiding this comment

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

How to get the latest value(single last updated )?

Copy link
Contributor Author

@anmolbabu anmolbabu Dec 15, 2016

Choose a reason for hiding this comment

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

like the time option, there needs to be one more option that internally does the graphite o/p parsing like we used to do before I'll add a sample for that as well

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add these details to the doc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


=== Security impact:

The apis exposed by Tendrl/performance-monitoring although are only getters,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the details here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. I'll update this soon. Looking through details on flask docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done added


==== Tendrl API impact:

The tendrl-api interfaces to the apis mentioned above under the section
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like see more details on how the tendrl-api to performance-monitoring interaction happens

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anivargi Can you please provide your inputs here

Copy link
Contributor

Choose a reason for hiding this comment

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

@nthomas-redhat Making call's to the monitoring app via a http client programatically. The API will define its own url's, somewhat similar to what API;s from the monitoring app. We need to take this approach since we need to have one point of interaction.

Copy link
Contributor

Choose a reason for hiding this comment

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

@anmolbabu @anivargi , Please add these details to the doc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Some of the config options as below need to be made available:

----
[time_series]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something to be covered as mentioned in - #11

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I'll remove it from here. Its anyway covered in #20 in lines 286 to 297

Copy link
Contributor

@brainfunked brainfunked left a comment

Choose a reason for hiding this comment

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

The document needs integration details from @anivargi as has already been pointed out. The point I'd like to be considered when adding these details is that the interface must appear to be uniform. To the client, it should not be apparent that there are in fact two separate APIs being accessed to provide this functionality.

** Interface to time-series db is designed in the form of plugins specific to
a time-series db.
*** This means that to support a new time-series db, all it takes is the
addition of its apecic interface as a plugin and doesn't require
Copy link
Contributor

Choose a reason for hiding this comment

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

"apecic"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

specific :)


== Proposed change

* Tendrl/performance-monitoring will expose apis to access performance data in
Copy link
Contributor

Choose a reason for hiding this comment

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

General tip: Don't indent the nested lists.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

touching any other part of the code.
*** The way the plugins work is :
**** The interfaces to time-series db are added under the directory
tendrl/performance-monitoring/time_series_db/dbplugins of
Copy link
Contributor

Choose a reason for hiding this comment

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

In that case, omit the tendrl/performance-monitoring prefix from the directory name, since you've mentioned the repository name at the end of the sentence anyway.

***** Since the manager is a singleton, there is only one instance
of it throughout the life of Tendrl/performance-monitoring
application which means all this house-keeping is done only
once during the lifecycle of the application.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Sample Request

----------
GET /monitoring/nodes/<node_name>/monitored_types
Copy link
Contributor

Choose a reason for hiding this comment

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

The node_name will need to be understood by the client making this API call somehow. Aren't the main APIs using node ids? The clients should not have to translate. All our APIs must use the same identifiers for objects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically, the problem is that, the stats are stored in graphite with node names and it is the collectd plugin that decides the name to be associated with a metric its like chosen prefix.node_name.resource_type.stat_type . If only we override the custom collectd plugins and write our own plugins, we'll be able to customize this name. But anyway instead of the api user having to do the mapping, the performance_monitoring application can as well do it using details in etcd. I'll modify the spec to reflect this

----------

The above response gives the statistics for last 24 hours corresponding to the
'resource_name' passed to it. If a time range is passed as optional arguements
Copy link
Contributor

Choose a reason for hiding this comment

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

There would be a maximum time range for which the data is stored in the time series db. Even if this isn't configurable right now, this value needs to be made known somehow.

Copy link
Contributor

Choose a reason for hiding this comment

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

And speaking of which, what's the way to change the duration for which the data would be stored in the db? Can this be done on the fly while the system is still pushing updates to the time series db?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have not thought of this before. I'll explore if there's a way to do this

Copy link
Member

Choose a reason for hiding this comment

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

Does graphite provide some sort of archiving mechanism and data which is older than say 2 yrs goes to archive??

Copy link
Contributor Author

@anmolbabu anmolbabu Dec 16, 2016

Choose a reason for hiding this comment

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

@shtripat I think I have seen something related to this. I'll explore more on this.
@shtripat @brainfunked can detailing on this go into a separate spec? As this spec is more about the procedure employed to access time series data and hence mainly exposing apis to do the same. I'll create a bug to track that and add a mention of that here.

Copy link
Member

Choose a reason for hiding this comment

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

@anmolbabu I am ok fro different spec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Raised an issue to track this : #99


----
[time_series]
time_series_db = graphite
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need to expose this option? Do we even support any db other than whisper?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The plan is to be able to support multiple time series dbs although there will be only 1 officially recommended. Any way its pluggable so the moment we add a plugin to different db, there'll be 2 types of dbs of which any one can be used. So, we have this field.

[time_series]
time_series_db = graphite
time_series_db_server = 0.0.0.0
time_series_db_port = 80
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the API run as root? It must not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's not actually a necessity. I just tried running flask the tool that we use for apis as non-root, non-sudo user and it works. And the graphite querying part also can work as any user its just a http get.


=== Work Items:

* https://github.com/Tendrl/performance_monitoring/issues/7
Copy link
Contributor

Choose a reason for hiding this comment

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

@anivargi please create an issue on the api repository and link it here.

Copy link
Contributor

Choose a reason for hiding this comment

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

@brainfunked Tendrl/api#43
I will write a specification before we start implementing this.

tendrl-bug-id: Tendrl#62
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
tendrl-bug-id: Tendrl#62
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Add security details + Details about monitoring-core api interactions

tendrl-bug-id: Tendrl#62
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Making call's to the monitoring app is via a http client programatically. The
tendlr-api will define its own url's, somewhat similar to what API's from the
monitoring app. We need to take this approach since we need to have one point
of interaction.
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess what you mentioned here was the APIs exposed by monitoring app. Its good to mention them as well here becuse, those are the one's exposed to the end user

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anivargi Could you please help me add it

* The default login auth cookie is alive for 365 days unless user explicitly
logged out. But this cookie alive period is exposed for configuration by
flask as a field by name 'REMEMBER_COOKIE_DURATION'.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does flask support token based auth?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nthomas-redhat As we discussed offline, this needs to be inline with the approach taken by tendrl-core api. So, I'll raise a different bug and correspondingly a different spec to address this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed offline I have added a reference to github issue that will address the auth part of monitoring stack

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue is @ #89

To get the statistics for a given time-range:

----------
GET /monitoring/nodes/<node_id>/<resource_name>/stats?from=1997-07-16T19:20+01:00&to=1997-07-18T19:20+01:00
Copy link
Contributor

Choose a reason for hiding this comment

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

What about time zones?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The time format employed is ISO 8601. I think this is standard followed by tendrl-api as well

So in case of 1997-07-18T19:20+01:00, +01:00 is offset from UTC time so with UTC as base time and offset mentioned the problem of time-zones is overcome

@anivargi could you please add if I am missing something

Copy link
Contributor

Choose a reason for hiding this comment

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

@anmolbabu yes, but is it possible for queries to be time zone specific and will they be resolved automatically and correctly or do we need to implement some UTC based time zone conversion to resolve such queries?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@brainfunked , The conversion needs to be implemented by us.

Copy link
Contributor

Choose a reason for hiding this comment

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

  • Always use aware datetime object, i.e. with timezone information. That makes sure you can compare them directly (aware and unaware datetime objects are not comparable) and will return them correctly to users. Leverage "pytz" to have timezone objects.
  • Use ISO 8601 as input and output string format. Use datetime.datetime.isoformat() to return timestamps as string formatted using that format, which includes the timezone information.

More here: https://julien.danjou.info/blog/2015/python-and-timezones

tendrl-bug-id: Tendrl#62
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
@nthomas-redhat
Copy link
Contributor

Looks good to me

Copy link
Member

@shtripat shtripat left a comment

Choose a reason for hiding this comment

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

LGTM. One question from @brainfunked need to be answered.

tendrl-bug-id: Tendrl#62
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
@r0h4n r0h4n merged commit ee0ae90 into Tendrl:master Jan 11, 2017
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.

6 participants