up
This commit is contained in:
parent
7202a98998
commit
f0814c40bc
5
Dockerfile
Normal file
5
Dockerfile
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
RUN fluent-gem install fluent-plugin-elasticsearch fluent-plugin-rewrite-tag-filter
|
||||
>>>>>>> Snippet
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
ElasticsearchURL string `json:"elasticsearch_url"`
|
||||
FluentdURL string `json:"fluentdURL_url"`
|
||||
}
|
||||
|
||||
// LoadConfig 从指定路径加载配置文件
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"elasticsearch_url": "http://fluentd.k8s.xunlang.home"
|
||||
"fluentdURL_url": "http://fluentd.k8s.xunlang.home"
|
||||
}
|
||||
|
||||
|
||||
|
8
fluentd-deployment.yaml
Normal file
8
fluentd-deployment.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
initContainers:
|
||||
- name: install-rewrite-tag-filter
|
||||
image: your-fluentd-image:version
|
||||
command: ["fluent-gem", "install", "fluent-plugin-rewrite-tag-filter"]
|
||||
containers:
|
||||
- name: fluentd
|
||||
image: your-fluentd-image:version
|
@ -5,9 +5,8 @@ import (
|
||||
"encoding/csv"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
cfg "gitea.zjmud.xyz/phyer/tanya/config"
|
||||
"io"
|
||||
|
||||
cfg "gitea.zjmud.xyz/phyer/tanya/config" // 请将your_project_path替换为实际的项目路径
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -143,8 +142,8 @@ func (cl *CandleList) ToCsv() (string, error) {
|
||||
return sb.String(), nil
|
||||
}
|
||||
|
||||
// ToEs 将Candle数据发送到Elasticsearch
|
||||
func (cl *CandleList) ToEs() error {
|
||||
// ToFluentd 将Candle数据发送到Fluentd
|
||||
func (cl *CandleList) ToFluentd() error {
|
||||
// 获取当前年份
|
||||
currentYear := time.Now().Year()
|
||||
|
||||
@ -240,7 +239,7 @@ func (cl *CandleList) ToEs() error {
|
||||
}
|
||||
|
||||
// 构造完整URL,添加json参数
|
||||
fullURL := fmt.Sprintf("%s/%s?json", strings.TrimRight(config.ElasticsearchURL, "/"), tag)
|
||||
fullURL := fmt.Sprintf("%s/%s?json", strings.TrimRight(config.FluentdURL, "/"), tag)
|
||||
|
||||
// 输出完整请求URL和请求体到日志
|
||||
fmt.Printf("Sending request to URL: %s\n", fullURL)
|
||||
|
@ -94,44 +94,19 @@ func (s *OkxPublicDataService) GetCandles(params CandlesRequest) ([]*Candle, err
|
||||
// 添加调试日志
|
||||
fmt.Printf("Making request to: %s\n", u.String())
|
||||
|
||||
// 创建自定义HTTP请求
|
||||
req, err := http.NewRequest("GET", u.String(), nil)
|
||||
resp, err := http.Get(u.String())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create request: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 设置请求头
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
// 发送请求
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("request failed: %v", err)
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
// 打印详细调试信息
|
||||
fmt.Printf("Request URL: %s\n", u.String())
|
||||
fmt.Printf("Response Status: %s\n", resp.Status)
|
||||
fmt.Printf("Response Headers: %v\n", resp.Header)
|
||||
|
||||
// 记录响应状态
|
||||
fmt.Printf("Response Status: %s\n", resp.Status)
|
||||
|
||||
// 读取并记录响应体
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read response body: %v", err)
|
||||
}
|
||||
|
||||
// 打印响应体长度和内容
|
||||
fmt.Printf("Response Body Length: %d\n", len(body))
|
||||
if len(body) > 0 {
|
||||
fmt.Printf("Response Body: %s\n", string(body))
|
||||
} else {
|
||||
fmt.Println("Response Body is empty")
|
||||
return nil, err
|
||||
}
|
||||
fmt.Printf("Response Body: %s\n", string(body))
|
||||
|
||||
|
@ -58,7 +58,7 @@ func TestCandleList_ToEs(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("ToEs failed: %v", err)
|
||||
}
|
||||
err = cl.ToEs()
|
||||
err = cl.ToFluentd()
|
||||
if err != nil {
|
||||
t.Fatalf("ToEs failed: %v", err)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user