No information going apm server/elasticsearch cluster

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text :slight_smile:

Kibana version: 6.6.1

Elasticsearch version: 6.6.1

APM Server version: 6.6.1

APM Agent language and version: java 1.4.0

Browser version:n/a

Original install method (e.g. download page, yum, deb, from source, etc.) and version: docker

**Fresh install or upgraded from other version?**fresh

Is there anything special in your setup? For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc. Nothing special

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant): Simple java jdbc to run a sql statement output results to system.out. But not seeing any information in elastic search. I have a spring boot app and that working fine. All this is running on my desktop and the ELK stack and database is running in docker containers.

Thanks for the help

Steps to reproduce:

  1. java -javaagent:/Users/steveo/elastic-apm-agent/java/elastic-apm-agent-1.4.0.jar -Delastic.apm.service_name=my-cool-service -Delastic.apm.application_packages=com.datawhisperers -Delastic.apm.server_urls=http://localhost:8200 -jar target/mavenproject2-1.0-SNAPSHOT-shaded.jar

**Code:
package com.datawhisperers.mavenproject2;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author steveo
 */
public class NewMain {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here

        try {
            Class.forName("org.postgresql.Driver");
            Connection con = DriverManager.getConnection(
                    "jdbc:postgresql://localhost:5432/drwho", "postgres", "sql");
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery("select * from drwho_actors");
            while (rs.next()) {
                System.out.println(rs.getInt(1) + "  " + rs.getString(2) + "  " + rs.getString(3));
            }
            rs.close();
            stmt.close();
            con.close();
        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        }
    }
}

Errors in browser console (if relevant):

Hi and thanks for using our agent :slight_smile:

In order to trace a span (JDBC span in this instance), it needs to made within a traced transaction (see more in our data model documentation).

Since this is done from the Main class, there is no active transaction. If you want to test such code, you can use our public API to create a transaction before and end end it after you make the DB query.
Alternatively, you can test your code from within a Servlet running on a supported servlet container.

I hope this helps,
Eyal.

Thanks. That worked.

For reference: I added @CaptureTransaction & @CaptureSpan before the main method

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.