Span Indices

edit

Spans are stored in separate indices of the format apm-[version]-span-[date]. Conceptually, spans are part of transactions.

Example documents

edit

See how span documents can look like when indexed in Elasticsearch:

{
    "events": [
        {
            "@timestamp": "2018-07-30T18:53:42.281Z",
            "context": {
                "service": {
                    "agent": {
                        "name": "elastic-node",
                        "version": "3.14.0"
                    },
                    "name": "backendspans"
                }
            },
            "parent": {
                "id": "abcdef0123456789"
            },
            "processor": {
                "event": "span",
                "name": "transaction"
            },
            "span": {
                "duration": {
                    "us": 141581
                },
                "hex_id": "abcdef01234567",
                "id": -9175013389437287000,
                "name": "GET /api/types",
                "parent": 3156441702022342700,
                "type": "request"
            },
            "timestamp": {
                "us": 1532976822281000
            },
            "trace": {
                "id": "fdedef0123456789abcdef9876543210"
            },
            "transaction": {
                "id": "01af25874dec69dd"
            }
        },
        {
            "@timestamp": "2018-07-30T18:53:42.281Z",
            "context": {
                "service": {
                    "agent": {
                        "name": "elastic-node",
                        "version": "3.14.0"
                    },
                    "name": "backendspans"
                }
            },
            "parent": {
                "id": "0000000011111111"
            },
            "processor": {
                "event": "span",
                "name": "transaction"
            },
            "span": {
                "duration": {
                    "us": 32592
                },
                "hex_id": "1234abcdef567895",
                "id": -7911509744411052000,
                "name": "GET /api/types",
                "parent": -9223372036568445000,
                "start": {
                    "us": 22000
                },
                "type": "request"
            },
            "timestamp": {
                "us": 1532976822281000
            },
            "trace": {
                "id": "abcdef0123456789abcdef9876543210"
            },
            "transaction": {
                "id": "ab45781d265894fe"
            }
        },
        {
            "@timestamp": "2018-08-01T10:00:00.001845Z",
            "context": {
                "service": {
                    "agent": {
                        "name": "elastic-node",
                        "version": "3.14.0"
                    },
                    "name": "backendspans"
                },
                "tags": {
                    "tag1": "value1"
                }
            },
            "parent": {
                "id": "abcdefabcdef7890"
            },
            "processor": {
                "event": "span",
                "name": "transaction"
            },
            "span": {
                "duration": {
                    "us": 3564
                },
                "hex_id": "0123456a89012345",
                "id": -9141386494764572000,
                "name": "GET /api/types",
                "parent": 3156442435030055000,
                "start": {
                    "us": 1845
                },
                "type": "request"
            },
            "timestamp": {
                "us": 1533117600001845
            },
            "trace": {
                "id": "abcdef0123456789abcdef9876543210"
            },
            "transaction": {
                "id": "ab23456a89012345"
            }
        },
        {
            "@timestamp": "2018-08-01T10:00:00Z",
            "context": {
                "service": {
                    "agent": {
                        "name": "elastic-node",
                        "version": "3.14.0"
                    },
                    "name": "backendspans"
                }
            },
            "parent": {
                "id": "ababcdcdefefabde"
            },
            "processor": {
                "event": "span",
                "name": "transaction"
            },
            "span": {
                "action": "call",
                "duration": {
                    "us": 13980
                },
                "hex_id": "abcde56a89012345",
                "id": 3156431159584433000,
                "name": "get /api/types",
                "parent": 3146835049025875000,
                "start": {
                    "us": 0
                },
                "subtype": "http",
                "sync": false,
                "type": "request"
            },
            "timestamp": {
                "us": 1533117600000000
            },
            "trace": {
                "id": "abcdef0123456789abcdef9876543210"
            },
            "transaction": {
                "id": "bed3456a89012345"
            }
        },
        {
            "@timestamp": "2018-08-01T10:00:00.00283092Z",
            "context": {
                "db": {
                    "instance": "customers",
                    "statement": "SELECT * FROM product_types WHERE user_id=?",
                    "type": "sql",
                    "user": "readonly_user"
                },
                "http": {
                    "method": "GET",
                    "status_code": 200,
                    "url": "http://localhost:8000"
                },
                "service": {
                    "agent": {
                        "name": "elastic-node",
                        "version": "3.14.0"
                    },
                    "name": "backendspans"
                }
            },
            "parent": {
                "id": "abcdef0123456789"
            },
            "processor": {
                "event": "span",
                "name": "transaction"
            },
            "span": {
                "action": "query",
                "duration": {
                    "us": 3781
                },
                "hex_id": "1234567890aaaade",
                "id": -7911603569559950000,
                "name": "SELECT FROM product_types",
                "parent": 3156441702022342700,
                "stacktrace": [
                    {
                        "exclude_from_grouping": false,
                        "filename": "net.js",
                        "line": {
                            "number": 547
                        }
                    },
                    {
                        "context": {
                            "post": [
                                "    ins.currentTransaction = prev",
                                "}"
                            ]
                        },
                        "exclude_from_grouping": false,
                        "filename": "file2.js",
                        "line": {
                            "number": 12
                        }
                    },
                    {
                        "abs_path": "net.js",
                        "context": {
                            "post": [
                                "    ins.currentTransaction = prev",
                                "    return result"
                            ],
                            "pre": [
                                "  var trans = this.currentTransaction",
                                ""
                            ]
                        },
                        "exclude_from_grouping": false,
                        "filename": "net.js",
                        "function": "onread",
                        "library_frame": true,
                        "line": {
                            "column": 4,
                            "context": "line3",
                            "number": 547
                        },
                        "module": "some module",
                        "vars": {
                            "key": "value"
                        }
                    }
                ],
                "start": {
                    "us": 2830
                },
                "subtype": "postgresql",
                "sync": true,
                "type": "db"
            },
            "timestamp": {
                "us": 1533117600002830
            },
            "trace": {
                "id": "abcdef0123456789abcdef9876543210"
            },
            "transaction": {
                "id": "aff4567890aaaade"
            }
        }
    ]
}