-
Notifications
You must be signed in to change notification settings - Fork 21
cmd/ido2icingadb: migrate history from IDO to Icinga DB #253
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some first comments for now.
b1a9720 to
70d901a
Compare
|
Now it should work as expected. Please have a look. |
70d901a to
3b3f6d2
Compare
def926e to
3eb22d9
Compare
|
1 rewrite, 42 quadrillion centuries and one s/Debian/Ubuntu/ later... |
3eb22d9 to
a2b2286
Compare
TODO
|
Setup
Full migration
|
cd8977e to
7936077
Compare
|
Do I understand correctly that the time range limitation also applies to populating the cache, i.e. it won't take earlier rows into account, even if they would hold information (like the previous state) for a later event within the migration time range? Not sure yet if that's good or bad. If you restrict the lower limit, you probably have a reason. If we want to fill as much as possible, we'd have to build the cache from the very beginning, so it might scan 5 years to migrate 1 year. That might not be desired, on the other hand, reading doesn't seem to be the bottleneck. |
|
Oh. You're right. 😅 |
cmd/ido2icingadb/misc.go
Outdated
| // slowlyIncrementingProgressDecorator is the base decorator | ||
| // for possibly slowly incrementing progresses possibly starting from >0%. | ||
| type slowlyIncrementingProgressDecorator struct { | ||
| decor.WC | ||
|
|
||
| // startProgress is the first progress >0 seen by Decor. | ||
| startProgress int64 | ||
| // startTime tells when is startProgress from. | ||
| startTime time.Time | ||
| // lastProgress is the last progress >0 seen by Decor. | ||
| lastProgress int64 | ||
| // lastTime tells when is lastProgress from. | ||
| lastTime time.Time | ||
| } | ||
|
|
||
| // update is to be called by Decor and returns whether sipd is warmed up. | ||
| func (sipd *slowlyIncrementingProgressDecorator) update(s decor.Statistics) bool { | ||
| if s.Completed || s.Current < 1 { | ||
| return false | ||
| } | ||
|
|
||
| if sipd.startProgress < 1 { | ||
| sipd.startProgress = s.Current | ||
| sipd.startTime = time.Now() | ||
| sipd.lastProgress = sipd.startProgress | ||
| sipd.lastTime = sipd.startTime | ||
|
|
||
| return false | ||
| } | ||
|
|
||
| if s.Current == sipd.startProgress { | ||
| return false | ||
| } | ||
|
|
||
| if s.Current > sipd.lastProgress { | ||
| sipd.lastProgress = s.Current | ||
| sipd.lastTime = time.Now() | ||
| } | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| // eta indicates the ETA for possibly slowly incrementing progresses possibly starting from >0%. | ||
| type eta struct { | ||
| slowlyIncrementingProgressDecorator | ||
| } | ||
|
|
||
| // Decor implements the decor.Decorator interface. | ||
| func (e *eta) Decor(s decor.Statistics) string { | ||
| if e.update(s) { | ||
| timePerItem := float64(e.lastTime.Sub(e.startTime)) / float64(e.lastProgress-e.startProgress) | ||
| lastETA := time.Duration(float64(s.Total-s.Current) * timePerItem) | ||
|
|
||
| return e.FormatMsg(((lastETA - time.Since(e.lastTime)) / time.Second * time.Second).String()) | ||
| } else { | ||
| return "" | ||
| } | ||
| } | ||
|
|
||
| // eta indicates ops/s for possibly slowly incrementing progresses possibly starting from >0%. | ||
| type opsPerSec struct { | ||
| slowlyIncrementingProgressDecorator | ||
| } | ||
|
|
||
| // Decor implements the decor.Decorator interface. | ||
| func (ops *opsPerSec) Decor(s decor.Statistics) string { | ||
| if ops.update(s) { | ||
| return ops.FormatMsg(fmt.Sprintf( | ||
| "%.0f/s", | ||
| float64(ops.lastProgress-ops.startProgress)/ | ||
| (float64(ops.lastTime.Sub(ops.startTime))/float64(time.Second)), | ||
| )) | ||
| } else { | ||
| return "" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The progress bars use the average from start to show rates and time estimates. Given that there are index updates involved when inserting, insert complexity should be (at least) logarithmic, i.e. how the insert rate progresses over time can be approximated by 1/ln(x). So inserting will likely only get slower over time (unless there's a magic performance improvement on the database server in the meantime), making the values displayed too optimistic.
Thus, I think displaying an average value over the last few minutes or transactions (to avoid having the exact numbers jump around like crazy) would produce more useful numbers here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth investing the time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't take that much time I think. Should just need a slice of progress/time pairs where you keep the last like 10 updates and then perform the same calculation just with the oldest and newest values from that slice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to continue reviewing while I'm on it.
d099855 to
649f7e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the inline comment, I think you can start doing the other things that will be needed to get this ready:
- Rename the
cmd/ido2icingadb/to the final name (probablyicingadb-migrateas it already says in the README). - Integrate the README into
doc/.
d1f1dc1 to
ec4750d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have a look at the paths, that rename went wrong.
ec4750d to
6a5f3fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code should be done now, just getting the docs ready left I think. In general, I miss a clear "do this because this will probably be what you want" with some "in some cases you might want this instead" options.
| type: pgsql | ||
| host: 192.0.2.1 | ||
| port: 5432 | ||
| database: icinga | ||
| user: icinga | ||
| password: CHANGEME | ||
| # Input time range | ||
| #from: 0 | ||
| #to: 2147483647 | ||
| # Icinga DB database | ||
| icingadb: | ||
| type: mysql |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd not mix database types here, might lead to confusion. I get that this is supposed to say that both types are supported, but I think that would be easier to understand if both occurrences said type: mysql # or pgsql for PostgreSQL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shall also express that cross-RDBMS-type migration is supported.
|
? |
? (If you're wondering about an incomplete sentence you've read in a notification e-mail, please read it again on the website.) (PS: I hate ISO keyboard layouts where the backspace and return key are directly next to each other.) |
|
Er, no, I've read #253 (review) on the website. |
|
I think for almost all users, the workflow of setting up Icinga DB in parallel and then migrating everything up to that point in time where they started running Icinga DB is what they want. With the current state of the documentation, they have to figure this out themselves but I think this should be documented as the way to go. This can then have extra sections for things like "If you only want to migrate the history for the last year, you can additionally set a start time" or "If you had trouble setting up Icinga DB in the first place, please double check that the time stamp obtained from the database makes sense". |
|
I've pushed a suggestion with how to improve the docs to the feature/migrate-history-docs branch. While writing the documentation, I asked myself why we even need to ask the user to provide an endpoint name. All |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge this now as-is as there are no real blockers in here anymore so that we can go on with other changes without introducing merge conflicts with this huge PR all the time. I'll open a new PR for the outstanding details.
No description provided.