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

backend: add /logs API for searching logs #3

Merged
merged 39 commits into from
Feb 26, 2020

Conversation

Deardrops
Copy link
Contributor

@Deardrops Deardrops commented Jan 7, 2020

This PR add a new API /api/logs for Dashboard backend.
For all available APIs, please run

SWAGGER=1 make server && ./bin/tidb-dashboard

and visit API documents generated by swagger:
http://127.0.0.1:12333/dashboard/api/swagger/index.html

Changes:

  • Add gorm package
  • Add comments for swagger

@Deardrops Deardrops changed the title backend: add /logs API for search logs backend: add /logs API for searching logs Jan 7, 2020
pkg/apiserver/apiserver.go Outdated Show resolved Hide resolved
@lonng
Copy link

lonng commented Jan 9, 2020

Do you mean the client should fetch logs of different components or instances individually? and sort them by time in the client?

@breezewish breezewish added the status/DNM Do not merge label Jan 9, 2020
@breezewish
Copy link
Member

@lonng This is a POC implementation. I have sent you a formal design.

.gitignore Outdated Show resolved Hide resolved
pkg/apiserver/logs/handler.go Outdated Show resolved Hide resolved
pkg/apiserver/logs/handler.go Outdated Show resolved Hide resolved
@breezewish breezewish removed the status/DNM Do not merge label Jan 14, 2020
Copy link
Contributor

@mapleFU mapleFU left a comment

Choose a reason for hiding this comment

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

Is pkg/apiserver/logs/task.go still WIP?

pkg/apiserver/logs/handler.go Outdated Show resolved Hide resolved
pkg/apiserver/logs/db.go Outdated Show resolved Hide resolved
@Deardrops Deardrops changed the title backend: add /logs API for searching logs [WIP]backend: add /logs API for searching logs Jan 19, 2020
@Deardrops Deardrops changed the title [WIP]backend: add /logs API for searching logs backend: add /logs API for searching logs Jan 20, 2020
@breezewish breezewish mentioned this pull request Feb 9, 2020
Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

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

Good job! I will have another detailed review tomorrow.

pkg/apiserver/logsearch/models.go Outdated Show resolved Hide resolved
pkg/apiserver/logsearch/models.go Outdated Show resolved Hide resolved
pkg/apiserver/logsearch/models.go Show resolved Hide resolved
pkg/apiserver/logsearch/models.go Outdated Show resolved Hide resolved
pkg/apiserver/logsearch/error.go Outdated Show resolved Hide resolved
pkg/apiserver/apiserver.go Outdated Show resolved Hide resolved
StatusPort: "10080",
},
}
taskGroupID := scheduler.addTasks(components, searchLogReq)
Copy link

Choose a reason for hiding this comment

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

Does a single search request contain multiple tasks?

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, a request will start a taskGroup, and it will start multiple tasks (one component per task).

pkg/apiserver/logsearch/router.go Outdated Show resolved Hide resolved
pkg/apiserver/logsearch/router.go Outdated Show resolved Hide resolved
pkg/apiserver/logsearch/router.go Outdated Show resolved Hide resolved
pkg/apiserver/logsearch/router.go Outdated Show resolved Hide resolved

type PreviewModel struct {
ID uint `json:"-" grom:"primary_key"`
TaskID string `json:"task_id" gorm:"index;type:char(36)"`
Copy link
Member

Choose a reason for hiding this comment

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

how about using simple auto increment int?

Copy link
Contributor Author

@Deardrops Deardrops Feb 14, 2020

Choose a reason for hiding this comment

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

It will increase code complexity, I'd keep using UUID.

pkg/apiserver/logsearch/router.go Outdated Show resolved Hide resolved
pkg/apiserver/logsearch/router.go Outdated Show resolved Hide resolved
pkg/apiserver/logsearch/router.go Outdated Show resolved Hide resolved
pkg/apiserver/logsearch/router.go Outdated Show resolved Hide resolved
pkg/apiserver/logsearch/router.go Outdated Show resolved Hide resolved
@breezewish breezewish merged commit f33d01f into pingcap:master Feb 26, 2020
@breezewish breezewish linked an issue Feb 26, 2020 that may be closed by this pull request
shhdgit pushed a commit to shhdgit/tidb-dashboard that referenced this pull request Jan 21, 2022
shhdgit pushed a commit to shhdgit/tidb-dashboard that referenced this pull request Jun 23, 2022
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.

Log Export API
6 participants