This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enhance log by elasticsearch and kibana
- Loading branch information
Showing
15 changed files
with
463 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package es | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/ozline/tiktok/config" | ||
"github.com/ozline/tiktok/pkg/constants" | ||
"github.com/ozline/tiktok/pkg/eslogrus" | ||
"github.com/sirupsen/logrus" | ||
|
||
elasticsearch "github.com/elastic/go-elasticsearch" | ||
) | ||
|
||
var ( | ||
EsClient *elasticsearch.Client | ||
) | ||
|
||
func EsHookLog() *eslogrus.ElasticHook { | ||
hook, err := eslogrus.NewElasticHook(EsClient, config.Elasticsearch.Host, logrus.DebugLevel, constants.APIServiceName) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return hook | ||
} | ||
|
||
// InitEs 初始化es | ||
func Init() { | ||
esConn := fmt.Sprintf("http://%s", config.Elasticsearch.Addr) | ||
cfg := elasticsearch.Config{ | ||
Addresses: []string{esConn}, | ||
} | ||
client, err := elasticsearch.NewClient(cfg) | ||
if err != nil { | ||
log.Panic(err) | ||
} | ||
EsClient = client | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.