-
Notifications
You must be signed in to change notification settings - Fork 526
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
Fix libbeat metrics replacement #7143
Conversation
2673eec
to
4a17630
Compare
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
/test |
1 similar comment
/test |
* systemtest: test elasticsearch metrics * beater: fix race with libbeat metrics replacement (cherry picked from commit c01f7b4) # Conflicts: # beater/beater.go
This pull request is now in conflicts. Could you fix it @axw? 🙏
|
@Mergifyio refresh |
✅ Pull request refreshed |
It seems that the current diff cannot be back ported as is to 7.17. |
confirmed with RC2: start apm-integration-test:
in the fleet ui:
create an agent:
monitoring:
enabled: true
use_output: default
namespace: default
logs: true
metrics: true
http:
enabled: true
host: localhost
port: 6791 Start the elastic-agent using the service token, policy id, and
add the apm-integration to the agent policy confirm the apm-server has been started: start metricbeat with the following # modules.d/beat-xpack.yml
- module: beat
xpack.enabled: true
period: 10s
hosts: ["http://localhost:6791"]
basepath: "/processes/apm-server-default" navigate to the stack monitoring ui ingest events with the following program: package main
import (
"context"
"fmt"
"os"
"time"
"go.elastic.co/apm"
)
func main() {
version := "undefined"
if len(os.Args) > 1 {
version = os.Args[1]
}
name := fmt.Sprintf("apm-server-%s", version)
for i := 0; i < 1000; i++ {
tx := apm.DefaultTracer.StartTransaction(name, "type")
ctx := apm.ContextWithTransaction(context.Background(), tx)
span, ctx := apm.StartSpan(ctx, name, "type")
span.Duration = time.Second
span.End()
tx.Duration = 2 * time.Second
tx.End()
<-time.After(time.Millisecond)
}
<-time.After(time.Second)
apm.DefaultTracer.Flush(nil)
fmt.Printf("%s: %+v\n", name, apm.DefaultTracer.Stats())
} verify that events appear in the output events rate graph |
Motivation/summary
Fix a race between apm-server and libbeat code replacing the
libbeat.output.events
metrics registries. When the output is reloaded, libbeat clears thelibbeat
registry, undoing any replacement made by apm-server code. Because the libbeat code caches thelibbeat
metrics registry at init time, we can remove it and replace it with a newlibbeat
metrics registry under our own control.Checklist
- [ ] Update CHANGELOG.asciidoc(not yet released)- [ ] Update package changelog.yml (only if changes toapmpackage
have been made)- [ ] Documentation has been updatedHow to test these changes
/stats
output, or stack monitoringRelated issues
Closes #7139